Forum Moderators: open

Message Too Old, No Replies

Database design question

what is the better approach

         

saarah

11:41 pm on Feb 4, 2008 (gmt 0)

10+ Year Member



Hey Guys
I'm new to database design and am trying to find the best approach to this problem.

I have 3 different types of groups
Group1 is for a particular product
Group2 is for a particular retailer
Group3 is for a particular amount

The rest of the fields are same for all groups.
So is this a good way of doing this:


groupID ¦ groupName ¦ Description ¦ startedBy ¦ groupType ¦ productID ¦ retailerID ¦ Amount
--------------------------------------------------------------------------------------------
1 ¦ test1 ¦ testing1 ¦ <userID> ¦ 1 ¦ <productID>¦ null ¦ null
2¦ test2 ¦ testing2 ¦ <userID> ¦ 2 ¦ null ¦ <retailerID> ¦ null
3¦ test3 ¦ testing3 ¦ <userID> ¦ 3 ¦ null¦ null¦ 24000

<userID> --> refers to user table
<productID> --> refers to product table
<retailerID> --> refers to retailer table

OR should I be creating a base group table and three other tables for each group


Group
---------
groupID
groupName
Description
startedBy
groupType

GroupType1
----------
groupID
productID

GroupType2
----------
groupID
retailerID

GroupType3
----------
groupID
amount


Any suggestions will be greatly appreciated.
Thanks

ZydoSEO

3:47 pm on Feb 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




The latter if the purpose of GroupType is to indicate whether a group is related to a product, retailer, or price... If each group will have a value for all three then I'd go with the first one.

However, I'm not quite sure what a 'group' is...

saarah

11:49 pm on Feb 5, 2008 (gmt 0)

10+ Year Member



Thanks for your reply...

A group basically refers to a group of users. There are other tables involved like GroupMembers that store all the members that belong to a particular group.

Coming back to your suggestion, that was my original idea too, to go with the second approach. But then I was thinking, just to capture 1 extra field like productID or retailerID or amount - should I create 3 new tables.

But I guess since not all groups are going to have all three values, it makes sense to capture them in a different table.

Thanks for your input.