create table person_data ( id_no int NOT NULL, surname varchar(100) NOT NULL, given_name varchar(100) NOT NULL )
And then tables consisting of 1:many data such as email addresses, phone numbers, etcetera. For example:
I recommend the use of a surrogate key (i.e. the id_no) because the person's name (the natural key) is subject to change. By using a stable surrogate key, you avoid having to change the key because it stays with the record until deleted.create table person_email ( id_no int NOT NULL email_address varchar(100) NOT NULL )
By using a 1:many table, you have the flexibility of dealing with multiple phone numbers or email addresses. By placing each in a separate row, you avoid the situation where you have multiple values in one field, which is a violation of First Normal Form, and of course by extension, Third Normal Form.
Why worry about normality? Because the power of a relation database lies in the elimination of redundancy, thereby increasing data integrity, and reducing time spent in maintenance. And as a previous reply pointed out, when you get to the point where you are using DBI::DBD to extract the information, you have fewer steps you need to take with Perl.
Good Luck
-----
"Computeri non cogitant, ergo non sunt"
In reply to Re: Building an SQL query
by cadfael
in thread Building an SQL query
by despair
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |