0

Hello:
Soon I will need to have my foriegn keys working. I have tried to set them up with no luck.

Could someone show me how to set the payee_uid below? I am using an Apache Derby Embbeded Db 10.5.3.
Thanks

stu_uid VARCHAR(11) PRIMARY KEY,
    stu_password VARCHAR(11),
    stu_lname VARCHAR(20),
    stu_mname VARCHAR(20),
    stu_fname VARCHAR(20),
    stu_gender VARCHAR(1),
    stu_dob DATE,
    stu_start_date DATE,
    stu_end_date DATE,
    stu_area_code VARCHAR(3),
    stu_phone VARCHAR(10),
    stu_address VARCHAR(20),
    stu_state VARCHAR(2),
    stu_zip VARCHAR(5),
    <!--
    payee_uid VARCHAR(11),
	-->
    stu_email VARCHAR(90)
2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by ceyesuma
0

Hi

in JavaDB (same as Derby) columns which are foreign keys can be denoted by: CONSTRAINT NameOfConstraint REFERENCES refTable(PK_of_refTable), see Derby manual p.68. There are also conventional table-level foreign key constraints like: FOREIGN KEY (a, b, c) REFERENCES refTable (a, b, c), see Derby manual p.72.

btw, I think that the code fragment posted in by you should be more complete and should show your try of defining foreign keys at least.

-- tesu

0

Thank you for the help

I have found a manual that I think that your are refering to.

Derby 10.5 manual

I was having trouble finding the page numbers listed but I have the html copied
Do you recomend the pdf ot the html?

I will work on creating a Constraint. Anything I Have for foriegn keys now is used in MySQL.

I am thinking something like this will work CITY_ID INT CONSTRAINT METRO_FK REFERENCES CITIES

Edited by ceyesuma: n/a

0

Very helpful, thanks that works great

stu_uid VARCHAR(11) PRIMARY KEY,
    stu_password VARCHAR(11),
    stu_lname VARCHAR(20),
    stu_mname VARCHAR(20),
    stu_fname VARCHAR(20),
    stu_gender VARCHAR(1),
    stu_dob DATE,
    stu_start_date DATE,
    stu_end_date DATE,
    stu_area_code VARCHAR(3),
    stu_phone VARCHAR(10),
    stu_address VARCHAR(20),
    stu_state VARCHAR(2),
    stu_zip VARCHAR(5),
    
    payee_uid VARCHAR(11) CONSTRAINT PAYEE_FK REFERENCES payee,
	
    stu_email VARCHAR(90)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.