October 31, 2008 at 10:23 am
I am developing asp.net using c# and SQL 2005 as backend database. I would like to know what is the best practice for class relationship implementation. Do I store the class in a Business Object table and the class relationship in a separate Relation Object table? What is the pros and cons? Or what is other better solution? I am in stage of design the object oriented database. Please advise and help me. Thanks.
November 1, 2008 at 7:32 am
May be I should give an example. Say I have a product class and I use product table to store the attribute and another class supplier and I use supplier table. Now I want to store the relationship between product and supplier. Say the relationship is product is supplied by many suppliers and supplier supplies many products. What is the best practice to implement this relationships. Do I use another separate table to store these relationships or other better implementation? Please advise me. Thanks.
November 1, 2008 at 9:27 am
That depends entirely on what you intend to use this relationship information for.
If you just want the database to enforce it, you could implement it as a one-to-many Foreign Key constraint.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
November 1, 2008 at 7:51 pm
How about many to many relationship? Thanks.
November 1, 2008 at 9:01 pm
Then you need a junction or mapping table to represent just that relationship.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
November 2, 2008 at 3:38 am
Other than adding a relation table, there is no other way? Thanks.
November 2, 2008 at 11:48 am
As far as I know.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply