16.7 Create WORK Table with FK Constraint

CONSTRAINT [constraint_name] FOREIGN KEY (col_name, ...) REFERENCES tbl_name (col_name,...) 
[ON DELETE reference_option] 
[ON UPDATE reference_option] 

action_option:

RESTRICT | CASCADE | SET NULL | NO ACTION

16.7.1 Create the WORK table with FK

CREATE TABLE WORK (
    WorkID               int                NOT NULL,
    Title                varchar(35)            NOT NULL,
    Copy                 varchar(12)            NOT NULL,
    Medium               varchar(35)            NULL,
    Description          varchar(1000)      NULL DEFAULT 'Unknown provenance',
    ArtistID             int                NOT NULL,
    CONSTRAINT  WorkPK                   PRIMARY KEY(WorkID),
    CONSTRAINT  WorkAK1                  UNIQUE(Title, Copy),
    CONSTRAINT  ArtistFK                 FOREIGN KEY(ArtistID)
                             REFERENCES ARTIST(ArtistID)
                                    ON UPDATE NO ACTION
                                    ON DELETE NO ACTION
    );

16.7.2 Run Reverse Engineer

  • Do reverse engineering on vrg.
  • In the resulting diagram, inspect the tables and their relationships.
Reverse Enigneer EER Diagram

Reverse Enigneer EER Diagram