Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old July 22nd, 2003, 11:08 PM
Kinivin Kinivin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: NJ
Posts: 16 Kinivin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wink database design logic

Dose up on your Ridalin. This one's for the patient.


I have the following dilemma. I need to organize data in the most efficient manner. These are the data specifications.

UserData - Table of Users (estimate of 2000 rows)

Each entry in UserData can create objects of "n" varieties (ObjectVariety[1], ObjectVariety[2], .., ObjectVariety[n]) (20,000 anticipated objects)

Each ObjectVariety[1-n] will have approximately 25 attributes that can be ascribed to it (SharedAttributes) (attributes will either be marked as True/False or have an integer value)

Each ObjectVariety[1-n] ALSO will have attributes unque to their Variety (ObjectAttributes[1-n])

Now, I have two ways to organize this database - I'm not sure if either of them is the best way to do it

==== OPTION 1 aka LONG APROACH: ====

TABLE NAME: UserData

TABLE NAME: Object
Foreign Key points to Object Varieties

TABLE NAME: ObjectVarieties

TABLE NAME: ObjectAttributeDescription
Description of EachAttribute Available
Foreign Key for each entry points to ObjectVarieties or is 0 implying its a shared attribute.

TABLE NAME: ObjectAttributes
Value of Each Attribute
Foreign Key points to ObjectAttributeDescription
Foreign Key poinst to the Object itself

==== OPTION 2 aka WIDE Approach: ====

TABLE NAME: UserData

TABLE NAME: Object
foreign key pointing to VarietyIndex

TABLE NAME: VarietyIndex
A column pointing to a tablename (ex: Variety1)

TABLE NAME: AttributesForVariety1
around 25 columns for each attribute
foreign key to Object

TABLE NAME: AttributesForVariety2
around 25 columns for each attribute
foreign key to Object

TABLE NAME: AttributesForVariety3
around 25 columns for each attribute
foreign key to Object

TABLE NAME: SharedAttributes
around 25 columns
foreign key to Object
foreign key to ObjectAttributeDescription

TABLE NAME: ObjectAttributeDescription
Description of Attribute [varchar]


----------------------------------------------------------------
Please tell me if any of these options is at all viable. Please keep in mind about 2000 users. About 10 objects per user. About 5 varieties. Each object will have around 50 Attributes (SharedAttributes + Attributes unique to Variety).

If you can point me in the right direction, i would be very grateful.

Last edited by Kinivin : July 22nd, 2003 at 11:11 PM.

Reply With Quote
  #2  
Old July 22nd, 2003, 11:44 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,266 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 23 h 15 m 4 sec
Reputation Power: 744
Don't do the multiple table approach.

Another option is using a lookup table:
Code:
table.users
ID
...

table.objects
ID
users.ID
...

table.attributes
ID

table.lookup
objects.ID
attributes.ID
Of course, my suggestion id dependent on my reidalin working

Reply With Quote
  #3  
Old July 23rd, 2003, 01:04 PM
Kinivin Kinivin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: NJ
Posts: 16 Kinivin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
helpful indeed. thanks.

Reply With Quote
  #4  
Old July 24th, 2003, 09:47 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,679 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 14 h 50 m 53 sec
Reputation Power: 688
I would not use your 2nd approach. It becomes a nightmare when you need that new attribute 6 months later.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > database design logic


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway