Search for question
Question

The SQL DDL statement below creates an Album table and a Song table. The CREATE TABLE

statements do not specify primary or foreign key constraints. The SHOW COLUMNS queries

show information about the Album and Song table columns.

Add three constraint clauses that specify primary and foreign keys, as follows:

1. Add a primary key constraint to the Album table's ID column.

2.

Add a primary key constraint to the Song table's ID column.

3.

Add a foreign key constraint to the Song table. This constraint specifies that the AlbumID

column refers to the Album table's ID column.

After the constraint clauses are added, the SHOW COLUMNS result tables will show "PRI" in

the Key column to indicate which Album and Song columns are primary keys, and "MUL" to

indicate which Song column is the foreign key.

Add a primary key

CREATE TABLE Album (

ID INT,

Title VARCHAR (60),

ReleaseYear INT

});

Add primary and foreign keys

CREATE TABLE Song (

ID INT,

Title VARCHAR (60),

Artist VARCHAR(60),

AlbumID INT

);

SHOW COLUMNS

FROM Album;

SHOW COLUMNS

FROM Song;

(6 points)

Fig: 1