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

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 for hfx642

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.