3 ms·
>For example, suppose I'm creating a history database of who owned what internet domain names at which times. If my table is one-to-one with domains, I can use
by whatshisface 5y ago
>For example, suppose I'm creating a history database of who owned what internet domain names at which times. If my table is one-to-one with domains, I can use the domain name itself as the primary key.
In your example, wouldn't that not work, because the same domain would be in the table twice with two different owners?
- adrianmonk 5y agoYou might have more than one table in the database. For example, you could have a table of current owners for quick lookup and a table of all owners for full history. For the current owners table, you'd use just the domain as a key. For all the full history table, you'd use domain + start date + end date as the key. So yeah, that makes it a weird example, but the point is that in neither table did you make up a synthetic key. In one table, you used a real-world fact (domain) as the key, and in the other table you used three real-world facts (domain plus two dates) together as a key.