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
what about the one to one relationships between tables ???!!
Moderator: General Moderators
Re: what about the one to one relationships between tables ???!!
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]
[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]