Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>At first blush I see all those tables as pointless. Perhaps <code>MakesModelsAndYears</code> is all you need. And then I'd reconsider its name. At the very least I'd drop the "And". At best I'd rename it "Cars"</p> <p><strong>Table Keys and Data Relationships</strong></p> <p>Not necessarily the same thing. A primary key uniquely identifies the rows of a given table. That's all. A foreign key is a "guarantee" that a given value exists on some other table. Data can be related by other than formally defined keys. We sometimes call these candidate keys. Oh, there is no law that says you must have a primary key in any given table.</p> <p>I've worked with databases where I often joined tables on other than primary and/or foreign keys. That just how the real data relationships worked out.</p> <p><strong>Data Normalization</strong></p> <p>As a general rule you want to avoid data <em>redundancy</em> across tables. However if your <code>Years</code> table row has only one column - "year" then what's the point of that (ditto for those other tables as well)? You essentially duplicate that data in <code>MakeModelsAndYears</code> pointing to it.</p> <p>And if you do keep <code>Model</code>, <code>Engine</code>, <code>Year</code>, <code>Makes</code> tables don't make the <em>stupid, boneheaded</em> mistake of creating "ID" column in your <code>Makes</code> table (ditto for all the tables) just so you don't have to store "Chevrolet" in the <code>MakeModelAndYears</code> table. Imagine looking at that table and all you see are numbers in row after row!! To display meaningful <em>information</em> you'll have to make lots of Joins - just to say "1960 Chevy 454 Hemi Impala". Now that is inefficient!</p> <p><strong>Indexes</strong></p> <p>What indexes you make is driven by how you'll be looking up data and the database's performance when doing so.</p> <p>Make indexes in particular for those columns that you may be joining or searching on but are not formal keys.</p> <p>Also multi-column indexes are great for those columns that you frequently search for together. And the index column order matters. I've seen a very significant difference when all I did was reverse the column order in a certain index. Your mileage may vary (pun intended). And yes, differently ordered indexes on the same columns may make sense depending on table sizes, join column order, lookup frequency. You'll just have to look at these things if/when you have performance issues.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload