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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:42:38+00:00 2026-05-30T23:42:38+00:00

How can I model a compatibility matrix database in sql server 2008; i.e. I

  • 0

How can I model a compatibility matrix database in sql server 2008;
i.e. I have 4 groups of design. If I select group 1 and group 4, my choices will influence group 2 and 3 and will make them unselectable because they are not compatible with my choices.

I’m a beginner, so my explanation might seems watery, pls forgive!

  • 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-30T23:42:39+00:00Added an answer on May 30, 2026 at 11:42 pm

    Any kind of “matrix” is essentially an M:N relationship, only in this case both “axis” of the matrix represent the same thing (“groups of design”). The M:N relationship of a table with itself can be modeled like this:

    enter image description here

    Assuming relationships are bidirectional, you should also add: CHECK(GROUP_ID1 < GROUP_ID2) in the COMPATIBILITY table. This would, for example, allow (1, 4), but prevent (4, 1) from being in the table.

    The example from your question would be represented by the following data in the database:

    GROUP:

    GROUP_ID
    --------
    1
    2
    3
    4
    

    COMPATIBILITY:

    GROUP_ID1    GROUP_ID2
    ---------    ---------
    1            4
    

    When user selects a group X, you’d run the following query to find which groups it is compatible with. The remaining groups are in-compatible.

    SELECT GROUP_ID1
    FROM COMPATIBILITY
    WHERE GROUP_ID2 = :X
    UNION ALL
    SELECT GROUP_ID2
    FROM COMPATIBILITY
    WHERE GROUP_ID1 = :X
    

    For 1, this would return 4 and for 4 it would return 1. In either of these cases, 2 and 3 would not be returned – a sign they are incompatible.


    On the other hand, if you want do disable 2 and 3 when 1 and 4 are selected, but not when just 1 or just 4 is selected, this is a different problem that would be more complicated to model in the relational paradigm. Let me know if that’s what you actually need…

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

Sidebar

Related Questions

I have a database called ApplicationName_Development running on SQL Server 2008 R2 Developer edition
Background: I have an application with athletes, each of these athletes (Athlete model) can
I see that EF can update a model based on an existing database schema.
I have a stored procedure in a test instance of a sql server (named
How can I load model to helper? I need to load it outside of
Using the WCF web programming model one can specify an operation contract like so:
I have a model, smth like this: class Action(models.Model): def can_be_applied(self, user): #whatever return
Can Permalink_fu combine 2 or more model attributes to create a unique permalink? Let's
I can't access my model's attributes in the after_create callback... seems like I should
Can I perform a dumpdata in Django on just a single model, rather than

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.