http://qs321.pair.com?node_id=187350


in reply to database strategy

To expand on Zaxo's point a little, if (when you build a new set of tables) you cannot easily define a "natural" primary key, it is perfectly acceptable to create an "artificial" key. The best method of doing this is with a "sequence" in your database.

A hint with normalisation: If you have more than one person at an address, you may create two tables:

  1. Names
  2. Addresses
You then may include an "address_id" (primary key from Addresses) column in your "Names" table, then if there are > 1 person at an address, you would put in the address_id, rather than the entire address detail.

This also has the advantage of flexibility. For example, if for some reason the address changes from street to road, you only have to update it in one spot, not two!

If you wanted to get right into normalisation, the basic idea is to not replicate the same data in more than one spot. For example, you may create a table that has all the different types of streets (street, road, place etc etc), then add that primary key into the address table.