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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:08:27+00:00 2026-05-19T02:08:27+00:00

I just wanted to throw this question out there to do a sanity check

  • 0

I just wanted to throw this question out there to do a sanity check on my ORM design to make sure the way I’m doing it isn’t some crazy anti-pattern. My situation is that in my design I have a class that has an association relationship with 4 other classes. So if I had classes A, B, C, D, and E classes B,C,D, and E would all have an “Has-An” relationship to Class A. Currently the only way that I know of in LINQ-To-Sql to define a relationship is through creating a foreign key column in A for every entity that has a relationship to it. While this works it has the disadvantage that in the database there is four columns where three of the columns will always be null. Is this just a limitation of ORM tools? Any advise or suggestions would be appreciated.

  • 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-19T02:08:27+00:00Added an answer on May 19, 2026 at 2:08 am

    So I forget the exact name for this type of association, but I believe it’s called Polymorphic association. It’s my understanding that LINQ Entities doesn’t support polymorphic associations the way that Ruby on Rails does, but what you’d want to do is:

    1. Create tables A, B, C, D, E without defining their relationships to one of each other.
    2. Assign a UniqueIdentifier column to each table (this is a GUID).
    3. Create a “Relationships” table (probably want to come up with a better name.
    4. The relationships table would have two columns. Something like Source and Destination and both would be of type GUID or UniqueIdentifier (I forget what MSSQL server calls it).

    The bad part is that MSSQL can’t enforce the foreign key relationship (this is why LINQ Entities doesn’t support it). So that’ll have to be done in your business logic or in a StoredProcedure.

    This does give you the option of adding a type F and use the same table to expressing a Has-A relationship between F and A.

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

Sidebar

Related Questions

Just wanted opinions on a design question. If you have a C++ class than
I've been doing some thinking about data redundancy, and just wanted to throw everything
Edit2: I just want to make sure my question is clear: Why, on each
Just wanted to know if there is a big chance to inject SQL While
Just wanted to write some recursion but can't check if the child is in
I just wanted to see if I could have your thoughts on the design
This might be a stupid question, but I just saw a question asking how
I just had this throw a compilation error while refactoring some legacy (hence VB.NET)
Just want to start out by saying this seems like a great site, hope
There's probably a Google search that'll answer this question but for the life of

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.