Page 1 of 1

what about the one to one relationships between tables ???!!

Posted: Wed Mar 10, 2010 2:13 am
by minos_mks
i have experience in sql oracle , and i need to know how can i make a relationships one to one between 2 table

thanx for your time

Re: what about the one to one relationships between tables ???!!

Posted: Wed Mar 10, 2010 4:09 am
by Weirdan
One to one is a variant of one to many where linking column in 'many' table has a unique (or primary) key:
[sql] CREATE TABLE customer (   id int UNSIGNED NOT NULL AUTO_INCREMENT,   name varchar(50),   -- ....   PRIMARY KEY(id));CREATE TABLE customer_profile(   customer_id int UNSIGNED NOT NULL,   -- ....   PRIMARY KEY(customer_id),   FOREIGN KEY (customer_id) REFERENCES customer(id) ON DELETE cascade ON UPDATE cascade); [/sql]