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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
minos_mks
Forum Commoner
Posts: 69
Joined: Thu Feb 04, 2010 1:58 am

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

Post 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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

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

Post 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]
Post Reply