arpowers Posted November 4, 2007 Share Posted November 4, 2007 hey everyone.. here is my question... when you are designing a relational database you have many different relations, is it better to assign a table to each 'type' of relation or to create a master relational table where all relations are defined. For example: rtbl_bananas_oranges rtbl_bananas_pears in contrast to: rtbl_relations.. containing the columns id(primarykey) .. object1_id.. object2_id then go into object_id table and see what type it is.. .... the reason I ask is it gets tedious to keep track of an objects ID as well as its type .. hopefully this makes sense, Im going crazy trying to figure out how to implement this.. Andrew Quote Link to comment https://forums.phpfreaks.com/topic/75970-relational-database-and-keeping-track-of-objects/ Share on other sites More sharing options...
pocobueno1388 Posted November 4, 2007 Share Posted November 4, 2007 You don't want to make a separate table specifying which field links to what in each of the other tables, that would get really confusing. Just store what you have to store to create the relationship. Here is an example TABLE customers TABLE orders TABLE items ---------------- -------------- ------------ customerID +---+ orderID +-- itemID name +-- customerID | name address itemID +-----+ price Quote Link to comment https://forums.phpfreaks.com/topic/75970-relational-database-and-keeping-track-of-objects/#findComment-384608 Share on other sites More sharing options...
arpowers Posted November 4, 2007 Author Share Posted November 4, 2007 thanks for the reply.. sorry I was a little unclear on this.. I'm working with many-to-many relationships here among different user types.. that changes things quite a lot. Quote Link to comment https://forums.phpfreaks.com/topic/75970-relational-database-and-keeping-track-of-objects/#findComment-384632 Share on other sites More sharing options...
pocobueno1388 Posted November 5, 2007 Share Posted November 5, 2007 Oops, sorry...my mistake. Take a look at these articles http://www.tonymarston.net/php-mysql/many-to-many.html http://www.tomjewett.com/dbdesign/dbdesign.php?page=manymany.php There are tons of results on Google for this. Quote Link to comment https://forums.phpfreaks.com/topic/75970-relational-database-and-keeping-track-of-objects/#findComment-384704 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.