Take, for instance, a table that holds credit card charges, a table that holds credit cards, and a table that holds users.
Each charge is associated with exactly one card, and each card is associated with exactly one user. A user may have multiple cards on file.
If I were to hold this data in a MySQL database in three distinct tables, like so:
charges:
---------------------------------------------
id | card | amount | description | datestamp
---------------------------------------------
5 | 2 | 50.00 | Example | 1369429422
cards:
------------------------------------------------------------------
id | user | name | number | cvv2 | exp_mm | exp_yy
------------------------------------------------------------------
2 | 1 | Joe Schmoe | 4321432143214321 | 555 | 1 | 16
users:
-------------------------------------------
id | first_name | last_name | email
-------------------------------------------
1 | Joe | Schmoe | joe@schmoe.co
Now, let's say that I want to access a user, given a charge. In order to get to the user, I would first have to look up the card associated with the charge, and then look up the user associated with the card. Obviously, in an example like this, speed would be negligible. But in other scenarios, I see this as being two queries.
However, if I stored the data like so:
charges
----------------------------------------------------
id | card | user | amount | description | datestamp
----------------------------------------------------
5 | 2 | 1 | 50.00 | Example | 1369429422
then the charge would be associated directly with a user. That, however, is redundant information, since that same data is stored in the cards table.
Thoughts?