So here is what I have so far.
DROP DATABASE IF EXSISTS CDDATA;
CREATE DATABASE CDDATA;
USE CDDATA;
CREATE TABLE CDs (
CDID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
CD1 VARCHAR(20) NOT NULL,
Price FLOAT(4) NOT NULL,
);
CREATE TABLE Customers (
CustomersID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
Name VARCHAR(40) NOT NULL,
PRIMARY KEY (CustomersID)
CONTRAINT CCD1
FOREIGN KEY CustomerCD (CustermersID)
REFERENCES CDs (CD1)
ON DELETE CASCADE
ON DELETE CASCADE
);
INSERT INTO CDs VALUES (1, "A Music CD", 2.44);
INSERT INTO CDs VALUES (2, "A Music CD", 3.23);
INSERT INTO Customers VALUES (null,
INSERT INTO Customers VALUES (null,
INSERT INTO Customers VALUES (null,
And this is what I have to do. Develop the following database:
-
A table CDs with
• title (String)
• price in $ - floating point -
A table Customers with
• name (String)
• a primary key of a CD as a foreing key
• the number of copies of this CD that the customer has purchased
Provide surrogate keys for every table!
Create SQL statements that model the following situations -
Customer "Gerald" bought 3 copes of "Thick as a Brick"
-
Customer "Joe" bought 12 copies of "Dustbowl"
So mainly I have questions about surrogate keys and the SQL statements at the end. Thankyou for any and all help!