If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Design help...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-11, 13:40
Moolkye Moolkye is offline
Registered User
 
Join Date: Oct 2011
Posts: 4
Design help...

I am trying to design a Lego Database, for my own use at home.
As I am sure many of you know, Lego bricks can come in many different types, and each of those types in many colors.

My question is this.
In designing this db I am trying to understand whether it is best to have a table containing just part numbers and their descriptions, and have a table for colors, and then have a relationship between the 2 to an adjoining table which contains then a unique ID for each piece in each color.

Or

Just have 1 table that has each part listed in each color as a unique record in that table.

I am so confused as to which is the preferred method, to access the data quickly.

Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 10-28-11, 14:00
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Does every piece come in every color?
Does Lego's own product identification numbering indicate color?
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #3 (permalink)  
Old 10-28-11, 14:02
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
With only one person entering and querying the data, it is perfectly fine to have one table. if you have several people entering the data, you may end up with something like this for "How many green pieces do I have?"
Code:
select count(*) 
from table 
where color = 'Green'
   or color = 'Emerald'
   or color = 'Gren'
   or color = ...well, you get the point.
Reply With Quote
  #4 (permalink)  
Old 10-28-11, 14:04
Moolkye Moolkye is offline
Registered User
 
Join Date: Oct 2011
Posts: 4
Each Part has it own unique Lego Part Number
Each Lego Color has it's own official Lego Color Name, but not a unique Number.
No, every part does not come in every color.
Reply With Quote
  #5 (permalink)  
Old 10-28-11, 14:06
Moolkye Moolkye is offline
Registered User
 
Join Date: Oct 2011
Posts: 4
Quote:
Originally Posted by MCrowley View Post
With only one person entering and querying the data, it is perfectly fine to have one table.
For now, I will be the only one entering data. However, at some point, I would love to pack this db out, and give it to some of my friends, so they could utilize it, however I do not want them to be able to edit the data. I want to do that on my own, solely. But that is down the road.
Reply With Quote
  #6 (permalink)  
Old 10-31-11, 12:56
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
The I'd go with a table of parts, a table of possible colors, and a many-to-many table joining the two.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #7 (permalink)  
Old 11-13-11, 01:49
Martin22 Martin22 is offline
Registered User
 
Join Date: Nov 2011
Posts: 30
Quote:
Originally Posted by blindman View Post
The I'd go with a table of parts, a table of possible colors, and a many-to-many table joining the two.
That is exactly what I would do. Just be sure when creating your associative entity, as many-to-many relationships cannot be saved, that you only put the two primary keys from the Part table (PartID) and the Color table (ColorID) in the associative entity.

Also, when naming your tables, keep them singular. It is much, much easier to manage.

I hope this helps!

Martin
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On