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 options converting from txt to MySQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-29-07, 07:32
roland-o roland-o is offline
Registered User
 
Join Date: May 2007
Posts: 4
Design options converting from txt to MySQL

I wanted to discuss some database design issues so I typed "database forums" into Google and "I'm Feeling Lucky" and here I am, so I am hoping there might be someone here who will indulge me.

I'm converting an old web application from using Perl and text files to use PHP and MySQL. There is a form in the application which requires a number of features of an object to be selected.

So by way of example an object is specified, after which its color could be defined as either red, green or blue. Then its shape could be defined as circle, triangle or square. Then its material as metal, wood or plastic. There are some twenty odd of these features to specify options for.

Now I was planning on having a table for each feature ie. a colors table, a shapes table and a materials table (each with a color, shape and material column - is that an acceptable naming convention?)

There are twenty different features so it seems like a lot of tables and also a lot of foreign keys in the "objects" table. Is that a sign of bad design? How many tables, all relating just to the same main table, is too many?

Would it be be better to have a "features" table with a column for "type". I guess "type" would have to be an id relating to a "featuretypes" table? This would be a problem for features with different data types though wouldn't it?

What are the implications of either of these options in terms of design, efficiency and future development of the application? Is there a completely different, better design solution? I particularly want to make it easy to add new object features and maintain current ones. A new feature of an object might possibly be any data type: varchar, int or boolean for example.
Reply With Quote
  #2 (permalink)  
Old 05-29-07, 08:16
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
what you are describing as the "features" table is the "one true lookup table"

it's not a good design, no

see OLAP design with Key Value Pairs
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 05-29-07, 09:18
roland-o roland-o is offline
Registered User
 
Join Date: May 2007
Posts: 4
Thanks for the really quick reply!

There are some useful links there with a lot of information to digest. Both the One True Lookup Table (OTLT) and the Entity-Attribute-Value (EAV) models are options I had considered without knowing that they were common ideas (common enough to have names!). I will resist the temptation to use either of them as I can see they could both lead to trouble.

I guess I will stick to the twenty separate tables unless there is another model you could suggest?

With these tables what naming convention is most acceptable? For example with a "shapes" table should the column name be "shapename", "shape", "name" or something else?
Reply With Quote
  #4 (permalink)  
Old 05-29-07, 09:33
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
the only column name i would not use is one which repeats the name of the table in the column name

but that's just me
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 05-29-07, 10:01
roland-o roland-o is offline
Registered User
 
Join Date: May 2007
Posts: 4
So just to clarify, in a table named "shapes" you wouldn't use "shapename" or "shape" as column names but you would use "name"?

Are there any negative implications to having these twenty tables all with a column named "name"? Should I try to be more creative with the column names?

Thanks again for your quick replies.
Reply With Quote
  #6 (permalink)  
Old 05-29-07, 10:13
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by roland-o
Are there any negative implications to having these twenty tables all with a column named "name"?
the only one that comes to mind is that if you use more than one of these columns in the same query, you will want to assign column aliases
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 05-29-07, 11:16
roland-o roland-o is offline
Registered User
 
Join Date: May 2007
Posts: 4
I think I can live with that.

Thanks for your time and help. Much appreciated.
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