简体   繁体   中英

Creating SQL table, foreign_key confusion

模式

One question, I have supervisor set as foreign key. He collect information through Activity Participant and take it from person ID.

Question:

How should I create the Activity table? what do I have to write down about supervisor?

CREATE TABLE activity
(
act_id VARCHAR(8) CONSTRAINT activity_pk PRIMARY KEY,
act_type VARCHAR2(20),
act_desc VARCHAR2(30),
act_date DATE,
mor_aft VARCHAR2(9),

);

A foreign key must reference a unique key of the referenced table. Either the table's primary key, or else a secondary unique key.

CONSTRAINT activity_sup_fk FOREIGN KEY (act_supVisor) 
  REFERENCES person(Person_id)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM