Re: Normalize ...relationships
| From: | l0t3k | Date: | Sat, 22 Mar 2003 03:54:14 +0000 |
| Subject: | Re: Normalize ...relationships | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-26553@lists.php.net to get a copy of this message | ||
Russell,
how about creating a mapping , or adding a "role" field to the sportsmen
table, where role is owner, etc. it all depends on whether a sportsman can
be multiple things (owner, hunter, etc) at the same time. if so you need a
mapping table.
for example
CREATE table sportsmen_role_map (
sportsmenID bigint (10)notnull,
roleID bigint (10) notnull,
PRIMARY KEY (sportmenID, roleID)
)
create table sportsmen_roles (
roleID bigint (10) notnull autoincrement,
roleName varchar(50) notnull,
PRIMARY KEY (roleID)
)
l0t3k
"Russell Griechen" <russgri@bellsouth.net> wrote in message
news:003e01c2f023$e4e48ba0$dd611442@oemcomputer...
> a table 'hound'
> contains ownerID, breederID.
> These both are to be normalized in a separate table as in:
> CREATE TABLE sportsmen (
> sportsmenID bigint (10)notnull autoincrement,
>
> Question: How? based on a sportsman can be a owner, breeder, hunter,
> President,
> Senator, Governor etc;
> CREATE TABLE hound (
> houndID bigint(10) NOT NULL auto_increment,
> houndname varchar(60) ,
> studbookID tinyint (4) ,
> sireID bigint (10),
> damID bigint (10),
> dob varchar (20) ,
> dod varchar (20) ,
> colormarkID int (10) ,
> ownerID bigint (10) ,
> breederID bigint (10) ,
> kennelID bigint (10) ,
> litterID bigint (10) ,
> health varchar (255) ,
> PRIMARY KEY (houndID),
> UNIQUE KEY (houndID),
> KEY hdid_2 (houndID,houndname)
> ) TYPE=MyISAM COMMENT='Hound Registry';
>