Thread: entity with multiple relations?
06-26-04, 14:59 #1Registered User
- Join Date
- Jun 2004
entity with multiple relations?
hey, I guess this will be my first message on your fine forum.
I have 3 entities of interest, and I am wondering how to form the relationships.
I have a 'shop' entity, a 'user', and an 'item'. Items are related to shop, until purchased, then they are related to user.
My question is, how do I form the relationship? I thought I could do it in two ways;
1) have multiple foreign keys in item, so maybe itemid, shopid, userid, and only use one of shopid userid at once.
2) use some kind of link table with itemid, and 'parententityname' or something
can anyone help?
06-26-04, 21:55 #2Registered User
- Join Date
- Sep 2003
- The extremely Royal borough of Kensington, London
If an item can only belong to one shop then the shop entity need not be related to item.
User is a many to many relationship with Item.
Your schema will therefore be:
UserPurchases(user_id, item_id, qty, date)Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.