db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Legolas Woodland <legola...@gmail.com>
Subject Re: How i can create a One-to-Many related tables ?
Date Wed, 30 Nov 2005 15:41:20 GMT
Andrus Adamchik wrote:
> 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 :)
>>
>>
>>
>
>

Thank you for reply
I read in a book that in a Master details relation there are two tables 
, one of them is  supplier table (is it the foreign key table or Primary 
key table ?)
and one Client table.
I also seen that people who know the relation , call them Parent , child 
tables.
but i can not understand which table is client /child  and which one is 
supplier / parent (if I'm true about parent child equality with supplier 
client.)

Mime
View raw message