db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: How i can create a One-to-Many related tables ?
Date Tue, 29 Nov 2005 16:00:07 GMT
One-to-many simply means that a table on to-many end has a foreign  
key matching primary key of to-one. Here is an example taken from  
Cayenne test cases run on Derby. DEPARTMENT - PERSON is one-to-many:


CREATE TABLE DEPARTMENT (DEPARTMENT_ID INTEGER NOT NULL, NAME VARCHAR  
(100) NOT NULL, PRIMARY KEY (DEPARTMENT_ID))

CREATE TABLE PERSON (DEPARTMENT_ID INTEGER, NAME VARCHAR (100) NOT  
NULL, PERSON_ID INTEGER NOT NULL, SALARY DOUBLE PRECISION, PRIMARY  
KEY (PERSON_ID))

ALTER TABLE PERSON ADD FOREIGN KEY (DEPARTMENT_ID) REFERENCES  
DEPARTMENT (DEPARTMENT_ID)


Cheers,
Andrus Adamchik


On Nov 29, 2005, at 6:42 PM, Legolas Woodland wrote:

> hi
> Thank you for reading my post.
> how i can make a one-to-many related tables ?
> can you pleas give me a sample :)
>
>
>


Mime
View raw message