Re: Design for Category Feature
- From: "--CELKO--" <jcelko212@xxxxxxxxxxxxx>
- Date: 14 Oct 2005 07:50:24 -0700
You need to fix you data element names. There is no such thing as a
"name_id" or just a "category".
CREATE TABLE Persons
(person_id INTEGER NOT NULL PRIMARY KEY
first_name VARCHAR (30) NOT NULL,
surname VARCHAR (30) NOT NULL,
etc... );
CREATE TABLE Contacts
(contact_category INTEGER NOT NULL
REFERENCES ContactCategories (contact_category)
ON UPDATE CASCADE
ON DELETE CASCADE,
person_id INTEGER NOT NULL
REFERENCES Persons(person_id)
ON UPDATE CASCADE
ON DELETE CASCADE,
PRIMARY KEY (contact_category, person_id));
CREATE TABLE ContactCategories
(contact_category INTEGER NOT NULL PRIMARY KEY,
contact_description VARCHAR(15));
Or if you have only a few categories that do not change very often:
CREATE TABLE Contacts
(contact_category INTEGER NOT NULL
CHECK (contact_category IN ('friend;, 'enemy', ..)),
person_id INTEGER NOT NULL
REFERENCES Persons(person_id)
ON UPDATE CASCADE
ON DELETE CASCADE,
PRIMARY KEY (contact_category, person_id));
.
- Follow-Ups:
- Re: Design for Category Feature
- From: davidbryce
- Re: Design for Category Feature
- References:
- Design for Category Feature
- From: davidbryce
- Design for Category Feature
- Prev by Date: Re: Normal form.
- Next by Date: Re: Normal form.
- Previous by thread: Design for Category Feature
- Next by thread: Re: Design for Category Feature
- Index(es):
Relevant Pages
|