question

deadreply avatar image
deadreply asked

One DB or Multiple

Hi, im a newbi in conception of DB

Question, is better to put all model cars ex: lexus,audi,bmw... with model in one table or a table for each vendor ? for the future its more easy to work with one table or multiple.

Thanks

databasemodel
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tonylodge avatar image
tonylodge answered

I would recommend one table to store a list of vendors and one table to store the models, referencing the correct vendor via a foreign key.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

deadreply avatar image
deadreply answered

@tonylodge Ok but can you explain why this method ? thanks

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tonylodge avatar image tonylodge commented ·

Sorry I wasn't very explanatory was I ?

It's all about good database design, you want each table to be a grouping of specific types of "things" or entities - could be customers, orders, in your case, cars etc.

So a vendor is a an entity, so is a car - hence seperate tables.

You don't want a different table for each car vendor because it would greatly complicate your queries when you want cars from more than one vendor, and it would mean adding a new table every time you added a vendor. You don't want to include vendor information in the car models table, because you will be repeating information.

It strikes me you could use some reading on the basics of database design. There are some good books out there but for a free starter I found this site:

Database structure and design

Hope this helps a little.

Best wishes,

Tony

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.