Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> One to One

One to One

From: rm <groups_at_rlmoore.net>
Date: 18 Mar 2007 19:01:51 -0700
Message-ID: <1174269711.533298.245540@e1g2000hsg.googlegroups.com>


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,
CONSTRAINT pk_customer PRIMARY KEY (customer_id), CONSTRAINT idx_primary_contact UNIQUE (primary_contact_id) )

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US