Database table setup

Rowboat

Senior member
May 25, 2007
200
0
0
What is the best method for storing this type of information in a database?

Would it be one table or two, if its two tables do you link them somewhere other than in queries?

Currently I have

make table
ID make
10 Ford
11 Honda

model table
ID model
100 F150
101 Focus
102 Accord
103 Civic

Do i create another table that relates them by ID?
Make Model
10 100
10 101
11 102
11 103

or do I join them into one table
ID Make Model
10 Ford F150
....

Or is there some other way that is much better?

Thanks for reading, I'm just trying to get my head around how to convert some of my spreadsheets into a database format and some things just don't come naturally to me.

 

QED

Diamond Member
Dec 16, 2005
3,428
3
0
I would put them in one table, but it depends...

If you have a "make" table with just two fields (ID and make), what extra information does "ID" give you that "make" does not? The "make" field should be unique among your entries, so you don't need the ID field-- leaving you with a make table with a single field-- which is, in most cases, a waste. Same thing for the "model table".

Just put them both into a single table, unless you need a table of just makes or just models for some other purpose...


 

reverend boltron

Senior member
Nov 18, 2004
945
0
76
I would go with the make_model table personally. I think it holds data integrity a bit better, but I'm not a SQL expert.
 

Rowboat

Senior member
May 25, 2007
200
0
0
Originally posted by: QED
I would put them in one table, but it depends...

If you have a "make" table with just two fields (ID and make), what extra information does "ID" give you that "make" does not? The "make" field should be unique among your entries, so you don't need the ID field-- leaving you with a make table with a single field-- which is, in most cases, a waste. Same thing for the "model table".

Just put them both into a single table, unless you need a table of just makes or just models for some other purpose...

Thanks for the input, i'll do it that way and see if there are any bumps in the road later on.

 

troytime

Golden Member
Jan 3, 2006
1,996
1
0
depends on the application really

but i would have a table for makes
and a table for models
and the table for models would have a column for make, and it would use the make_id from the make table
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,591
5
0
Originally posted by: troytime
depends on the application really

but i would have a table for makes
and a table for models
and the table for models would have a column for make, and it would use the make_id from the make table


:thumbsup:


If you every wanted to pull up all of one model, numeric indexing is more efficient that string matching.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Originally posted by: Common Courtesy
Originally posted by: troytime
depends on the application really

but i would have a table for makes
and a table for models
and the table for models would have a column for make, and it would use the make_id from the make table


:thumbsup:


If you every wanted to pull up all of one model, numeric indexing is more efficient that string matching.

The only time you need a 3rd table is when you have a 'has many and belongs to' relationship. If it's strictly multiple childs per parent there's no reason to have a 3rd table, just reference the parent_id in the child table like the above posters have said
 

drebo

Diamond Member
Feb 24, 2006
7,035
1
81
Personally, I would do it this way:

Table 'make':
mfg_id (pk)
mfg_name

Table 'model':
model_id (pk)
mfg_id (fk)
model_name

No need for three tables, as this is only a one-to-many relationship. Three tables is only needed for many-to-many. As a model will only ever have one maker (at least in the context of this example (cars)), you will never have a many-to-many.
 

presidentender

Golden Member
Jan 23, 2008
1,167
0
76
Originally posted by: drebo
Personally, I would do it this way:

Table 'make':
mfg_id (pk)
mfg_name

Table 'model':
model_id (pk)
mfg_id (fk)
model_name

No need for three tables, as this is only a one-to-many relationship. Three tables is only needed for many-to-many. As a model will only ever have one maker (at least in the context of this example (cars)), you will never have a many-to-many.

:thumbsup::thumbsup:
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |