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 7608655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:58:24+00:00 2026-05-31T00:58:24+00:00

I have a list of objects (called Phases) that I’m storing in a db

  • 0

I have a list of objects (called “Phases”) that I’m storing in a db table.

I need to maintain the order of the Phases in the list. I’m wondering what’s a good way to model this?

I’m thinking I’ll give the Phase object an “int sequence” attribute that dictates the order and since it’s persisted to the table, I can read them back in order. The only problem I see is that when I change the order of the sequence, I have to recalculate all the sequence values for every Phase in the list. Example, swap the positions of #2 and #3 causes everything after #3 (say up to #1000) to have to be updated in the db too.

Is there an easier way to model this that I have not considered?

  • 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-05-31T00:58:25+00:00Added an answer on May 31, 2026 at 12:58 am

    I’d do it the way you described.

    Yes if you want to insert new values, then if you’ve used consecutive rank values then you need to bump existing values, say

    UPDATE table SET rank = rank + 1 WHERE rank >= ?
    

    It follows that you can’t usually make the rank column be unique because you don’t know what order the UPDATE will be processed in.

    If you’re accessing the database programmatically, you could allow non-consecutive rank values, so existing ranks only need to be bumped when there isn’t a gap in the numbering sequence.

    Also, if you are using a row/page-based database, you could consider taking rankings out to a separate table which just has the ID of the main record, and the rank value. Then if you did need to make mass updates to rankings, you wouldn’t be having to read and write entire main records, but just tiddly records containing a couple of integers.

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

Sidebar

Related Questions

I have a list of objects, called Attributes, that, essentially, i need to do
I have a parent object called Page that has a List of objects called
I have a DataGridView that is bound to a list of objects called BaseChange.
I have a list of objects in C# that have a property called 'Sequence'.
I have a class called Foo that defines a list of objects of type
I have a List<T> that is holding several objects called tc of type TwitterCollection
Imagine I have a list of objects that implement an interface called ISummary The
I have List where myObj has it own list of objects called example mySubObj.
I have a list of objects called Activity: class Activity { public Date activityDate;
If I have a list of objects called Car: public class Car { public

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.