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)

Recommended Answers

All 3 Replies

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

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

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)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.