Structuring your data
In a database, there are rules about where different entities are stored. For instance, everything about the customers should be stored in the
Customers table. A customer identifier is stored in this table, which means that the necessary data can be retrieved by a simple lookup in the
Customers table. So, if you need to refer to a customer from another table, you just store this identifier in the other table.
The identifier needs to be unique in the
Customers table, so that every record can be addressed. Here the field is called a primary key. In other tables, duplicates may exist. For example, several records in the
Orders table might refer to the same customer. If this is the case, the key is called a foreign ...