Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: database strategy

by Ryszard (Priest)
on Aug 03, 2002 at 16:31 UTC ( [id://187350]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://187350]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-18 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found