Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9105061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:00:34+00:00 2026-06-17T02:00:34+00:00

How will you design a table datastructure for lookup? I basically have to represent

  • 0

How will you design a table datastructure for lookup?

I basically have to represent the following table

Country             Activity        Legal_Age
European            Drink           18
European            Drive           21
American            Drink           21
American            Drive           18

Here my Key is (Country & Activity) and the value is Legal_age.

I thought of using std::map to breakdown this problem (into individual maps) as follows.

national_Activity_age_map

European            European_Activity_age_map
American            American_Activity_age_map

European_Activity_age_map

Drink           18
Drive           21

American_Activity_age_map

Drink           21
Drive           18

But the problem here is, as the number of columns to the original table keeps growing, the number of maps to be added and maintained keeps growing.

Let’s say the US chooses to have seperate drinking ages for US-citizens and non-citizens. Then I will have to add new mappings and also modify existing mappings.

Is there a simple & a clean way to represent this data in a DataStructure which takes in a multiple factored Key and produce one value?

There are a few similar questions like below but nothing answers my specific problem.
What datastructure would you use to represent this format of data?

Update:
I can’t use Boost features at work since it has to be ported (or something like that). Is there a C++ (gcc 4.1.2) feature that I can use.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:00:35+00:00Added an answer on June 17, 2026 at 2:00 am

    Try Boost Multi-Index.

    The Boost Multi-index Containers Library provides a class template named multi_index_container which enables the construction of containers maintaining one or more indices with different sorting and access semantics. Indices provide interfaces similar to those of STL containers, making using them familiar. The concept of multi-indexing over the same collection of elements is borrowed from relational database terminology and allows for the specification of complex data structures in the spirit of multiply indexed relational tables where simple sets and maps are not enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following database design: Employee Table: Username, Name, JobTitle, BadgeNo, IsActive, DivisionCode
I have the following database design: Answers Table: AnswerID, Answer QuestionAnswers Table: ID, QuestionID,
I have the following database design: Employees Table: EmployeeID, Name, OrgCode Departments Table: OrgCode,
I have a system I am trying to design that will retrieve information from
I have to develop an application with which my client will do visual design.
I have to design a database which will allow me store data in multiple
I have an SQL table with the following structure: Code1 - int Code2 -
which will be the best approach for a table design for keeping statuses for
Consider the following design: Company TABLE ( CompanyId int NOT NULL IDENTITY PRIMARY KEY,
I'm trying to design a table that will help me determine if a licence

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.