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

  • Home
  • SEARCH
  • 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 8013853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:45:00+00:00 2026-06-04T19:45:00+00:00

I have a table that needs each row to store an ordered collection of

  • 0

I have a table that needs each row to store an ordered collection of rows of the same type.

e.g., I am imagining something similar to:

class blah
{
   float yetMoreData;
};

class foo
{
   int data;
   String moreData;
   blah[] anOrderedCollectionOfBlahClasses;
};

What would be the best way to achieve this?

  • 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-04T19:45:02+00:00Added an answer on June 4, 2026 at 7:45 pm

    You want Blah and Foo to be separate tables, where Blah has a many-to-one relationship with Foo. The records in the Blah table should have a foreign key foo_id, identifying their parent Foo record. Blah also has an index_in_array attribute that allows the results to be sorted.

    CREATE TABLE Foo (
        id BIGINT,
        data INT,
        moreData CHAR(50)
    );
    
    CREATE TABLE Blah (
        id BIGINT,
        yetMoreData DOUBLE,
        foo_id BIGINT,
        index_in_array INT
    );
    

    If you want to get all the Blahs of a given Foo (say, the Foo with the ID of 5), use:

    SELECT * FROM Blah
    WHERE Blah.foo_id = 5
    ORDER BY Blah.index_in_array;
    

    If you’re ordering records, usually it shouldn’t be by something arbitrary (unless that arbitrary order was chosen specifically by the user, e.g., sorting the items on a to-do list). Normally, you sort on some “naturally-occurring” property of the data, like the date it was added or alphabetically by name, etc.

    N.B.: This answer is meant to be pseudocode SQL — make sure you adapt it to your specific database syntax before you toss it into a script. (And don’t forget to add some keys and indexes!)

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

Sidebar

Related Questions

I have a monthly table that needs to be translated for each languages Something
I have a table row that needs to be hidden when the anchor with
I have a small app that periodically needs a table row added to the
I have a table that's used to store some temporary bookkeeping stuff. It needs
I have a table where each row needs a timestamp marking the time it
I have a fact table that needs a join to a dimension table however
I have table that contains more than 12 millions of rows. I need to
I have a temp table that needs the values of a Stored procedure. So
I have a database table that stores imported information. For simplicity, its something like:
I have a table that has 4 rows, the first to ID them, and

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.