The decision between choosing a relational model over a de-normalized model is typically one of scale and the type of database operations that you anticipate most likely to occur.
A relational database is typically easier to query on and is more efficient for transactional heavy applications while a denormalized schema will be more appropriate if you plan on storing a large warehouse of data that you plan to run analytics or reports on.
If time is your bigger concern and you don't believe this site will have much traffic over the long term then by all means choose schema 1, but I recommend documenting the reasoning behind your eventual decision in the chance that someone else might be maintaining your work in the future and may be struggling with a feature that is at odds with your schema decision.
Myself, I would take the time to make it as relational as possible, but I am a perfectionist.
ProTip: Consider adding VIN number as a natural key to the vehicle table. It will help you identify individual vehicles and it relates to a real easily identifiable attribute of a real vehicle.
Ultimately, it comes down to use and architecture.
Architecture
Does the system handle "any sport"? Is the idea that you put on your architecture astronaut hat, and build a generic system that can handle any future type of sport that may not even exist today?
If so, obviously having dynamically-named tables is a huge pain, so it would make sense to have a schema that supports n sports, if required.
That said, I have a very strong bias against this approach: this is almost always more work and leads to poorer results. Making a separate UI, schema, etc, for each sport will ultimately lead to better user experience and easier to maintain code, even if it does mean some superficial amount of duplication (how to avoid/minimize this is a separate question).
How do you handle players that play multiple sports? Do they get two entries (eg, you treat as different people) or are you trying to do something specific with them?
Use
So let's assume you don't do sports dynamically (eg, if someone wants to add a new sport, it requires development effort to add it).
Is there ever a time where you're displaying players (or any other object you mentioned) from more than one sport at a time?
I could see this for a search function, where you could search by player or team name (regardless of sport), but beyond that I can't imagine many use cases.
If you never need to do this, then your approach is perfectly fine. You can stop reading here.
Alternative Schemas
Views
I'm a fan of KISS. In 15+ years of software development, I continue to fall back to the philosophy "build the simplest thing that works".
So my initial reaction, assuming a cross-sport search function is really the only use case, is to create views:
SELECT PlayerName, 'NFL' as [Sport], TeamName FROM NFL_Players JOIN NFL_Teams ...
UNION
SELECT PlayerName, 'NHL' as [Sport], TeamName FROM NHL_Players JOIN NHL_Teams ...
UNION ....
Of course, if you add a new sport, you have to add to the view. It may also be useful to include other common information but really that's dependent on what needs to get shown.
I'd try to keep all the sport-specific stuff in the View definition, so the search code doesn't need to have much or any specific code (besides maybe knowing how to link to /nhl/players/player-name
vs /nfl/...
or however your app does that).
Table Inheritence
Table inheritance can work, but is pretty complex. I don't have a ton of experience with it, and in fact, I think every time I've been involved in evaluating it we ended up doing something simpler (like I'm suggesting here).
So personally, I have yet to find why this would be useful, but maybe there is a convincing use case (that I don't know of) that justifies the complexity (eg, Table inheritance solves the use case better than any other solution).
Separate tables for sport-specific attributes
You could do a single players
table which has attributes common to all players of all sports, and then another set of tables like nhl_players_details
that contains a playerId and columns with additional info on the player. If there are a ton of common attributes, or you have many uses of "all players from all sports" then this may make sense.
Key value pairs for sport-specific attributes
Completely alternative approach: have a players
table (again, with common attributes like name) and then a player_data
table that has PlayerId
, Sport
, Attribute
, Value
. The attribute names entered would be sport-specific. This allows you to essentially add new attributes without modifying the schema (your code would still have to know to load/display them of course). The drawback is you lose some integrity: value would typically be a string field, so your app code would have to be resilient and handle potential failures converting the string value
to a specific data type (like integer).
This concept can of course apply to Teams, Games, etc.
Best Answer
The performance argument is usually the one which is most intuitive. You especially want to point out how it will be difficult to add good indexes in an incorrectly normalized database (note: there are edge-cases where denormalization can in fact improve performance, but when you are both inexperienced with relational databases you will likely not easily see these cases).
Another is the storage size argument. A denormalized table with lots of redundancies will require far more storage. This also plays into the performance aspect: the more data you have, the slower your queries will be.
There is also an argument which is a bit harder to understand, but is in fact more important because you can't solve it by throwing more hardware at it. That's the data consistency problem. A properly normalized database will take care by itself that a product with a specific ID always has the same name. But in a denormalized database such inconsistencies are possible, so special care needs to be taken when it comes to avoiding inconsistencies, which will take up programming time to get right and will still cause bugs which will cost you in customer satisfaction.