Hey guys, I'm having an issue understanding how to write a table that uses an id and another id which both have dual keys. What I mean by dual keys is they use primary key and foreign keys.

Example:

Table Name = Enrollment
Column Name = Sid, Csecid, Grade
Data Type = NUMBER, NUMBER, NUMBER
Lgth = w/e,w/e,w/e
PK = Sid, Csecid
FK = Sid, Csecid
Check = A,B,C,D,F,I

I'm having issues writing it out in SQL code such as Create Table Enrollment... etc

Recommended Answers

Just refer to the standard EMP and DEPT tables of SCOTT schema.

Try to analyze that , you will be able to write your own.

Jump to Post

All 2 Replies

Just refer to the standard EMP and DEPT tables of SCOTT schema.

Try to analyze that , you will be able to write your own.

Member Avatar

Primary Keys SHOULD be a single column with unique values.
Foreign Keys SHOULD be a single column refering to Primary Keys.
If you want uniqueness of multiple columns (in a single record), create a Unique Key.
Keep it simple!

Be a part of the DaniWeb community

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