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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:00:17+00:00 2026-05-26T17:00:17+00:00

I am designing a many-to-many relationship between two models: Cell and Isolator : CREATE

  • 0

I am designing a many-to-many relationship between two models: Cell and Isolator:

CREATE TABLE `isolator` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(127) NOT NULL,
  `surname` varchar(127) NOT NULL,
  PRIMARY KEY (`id`),
);

CREATE TABLE `cell` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(127) NOT NULL,
  `gen` varchar(127) NOT NULL,
  PRIMARY KEY (`id`),
);

CREATE TABLE `cell_isolators` (
  `cell_id` bigint(20) NOT NULL DEFAULT '0',
  `isolator_id` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`cell_id`,`isolator_id`),
  CONSTRAINT `cell_isolator_id` FOREIGN KEY (`isolator_id`) REFERENCES `isolator` (`id`),
  CONSTRAINT `isolator_cell_id` FOREIGN KEY (`cell_id`) REFERENCES `cell` (`id`) ON DELETE CASCADE
);

The client has asked me the possibility of specifying the order on which the list of isolators for a cell is shown, since it’s important for publication purposes.

What is the best approach to model that? I was thinking on adding a third field to the many-to-many relation (e.g. sort_order), but I would like to know if there are other alternatives.

Thanks!

  • 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-26T17:00:17+00:00Added an answer on May 26, 2026 at 5:00 pm

    The only way to do that in the general case is to add a column to “cell_isolators”.

    The data type is application-dependent to a certain extent. I’ve seen this done with columns as integers, floats or decimals, and alphanumerics (varchar(n)).

    Populating and maintaining it can be troublesome, though. That doesn’t have anything to do with the database design; it’s just painful to maintain the sort order for more than a few rows, especially if there are regular inserts to the table and changes to the sort order. Fortunately, that job usually falls to the user interface, not to the dbms.

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

Sidebar

Related Questions

I have a many to many relationship between entities and there is a table
I am designing a website which will involve too many photos. There are two
I am currently designing a role based authentication system for resources where many users
We are designing a SQL Server database with link tables for many-to-many relations. The
When designing an application, does there come a point where you have too many
When designing a database to use MVCC (Multi-Version Concurrency Control), you create tables with
While designing a table my colleague here says that I should avoid identity column
When designing user table what would be the must have fields from the security/user
When designing a collection class, is there any reason not to implement locking privately
I was just designing this application and made many .aspx files which have my

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.