Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> One to One
I am trying to create a one to one releationship between two tables.
The tables and the constraints are described below. I do not believe
that I am accomplishing my goal.May I please have a input?
The business rull is that one person should exist as the primary contact for the customer.
CREATE TABLE CUSTOMER
(
customer_id NUMBER NOT NULL, customer_type VARCHAR2(32 BYTE) NOT NULL, customer_display_name VARCHAR2(35 BYTE) NOT NULL,primary_contact_id NUMBER NOT NULL,
CREATE TABLE PERSON
(
person_id NUMBER NOT NULL,
first_name VARCHAR2(15 BYTE) NOT NULL,
middle_initial CHAR(1 BYTE),
last_name VARCHAR2(25 BYTE) NOT NULL,
telephone_number CHAR(10 BYTE) NOT NULL,
email_address VARCHAR2(35 BYTE),
notes VARCHAR2(50 BYTE),
CONSTRAINT pk_person PRIMARY KEY (person_id)
)
ALTER TABLE PERSON ADD (CONSTRAINT fk_primary_contact FOREIGN KEY
(person_id) REFERENCES CUSTOMER (primary_contact_id));
Received on Sun Mar 18 2007 - 21:01:51 CDT