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 > I am very confused.....

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-24-11, 14:30
sinan sinan is offline
Registered User
 
Join Date: Jul 2011
Posts: 2
I am very confused.....

hi guys.. i am designing a brand new car database system.. I create entity-relationship model but it seems garbage.i uploaded the model.
I am very confused.....-car.jpg
When i want select something in database i write lots of absurd codes like
'SELECT
brand_name,model_name,fuel_type,car_type,engine_lt ,price FROM
brand,model,fuel,cartype,engine WHERE
car.brand_id=model.brand_id and
car.model_id=model.model_id and
car.fuel_id=fuel.fuel.id and
car.cartype_id=cartype.cartype_id and
car.engine_id=engine.engine_id; '

Is this right way or are there any easy ways to do that database..?
Reply With Quote
  #2 (permalink)  
Old 07-24-11, 17:41
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
looks over-engineered to me

for example, take fuel_type -- why would you split that off into a separate table? why wouldn't you just have fuel_type as an attribute of the car?

well (he said, answering his own question), the only possibility i can think of is that you want a controlled vocabulary -- you want people entering data for a car to be restrictred to only the values of fuel type that have already been predefined in the fuel table, using a foreign key relationship

if that's true, then my next question question is, why would you use an id for that, instead of the actual fuel_type value?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 07-24-11, 18:01
sinan sinan is offline
Registered User
 
Join Date: Jul 2011
Posts: 2
yeah you absolutely right r937 and car type table is silly too.. So you say that drop car_type and fuel tables.. Take that values in car table.. And its okey right?

But i want to ask something another thing you called controlled vocabulary..Can you tell more about that topic because i am curious..

Last edited by sinan; 07-24-11 at 18:11.
Reply With Quote
  #4 (permalink)  
Old 07-24-11, 18:18
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
google it
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 07-26-11, 15:39
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
He means that you are trying to ensure the values are always spelled the same, which can be almost gauranteed through the use of a foreign key that E-89 is what gets into the car table rather than sometimes you have E-89, E89, Ethanol89 and so on. The reason I say almost gauranteed using foreign keys as you have defined already, the other spellings could be added to your fuel table and then make it into your car table. Most places I have been have had a single code table of some sort and you use those codes as a drop down for selection, to try to ensure you get the correct value, rather than having a 100 or more tables that contain a couple of values and their codes, such as fuel type car type etc...
Dave Nance
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