Description
Objective: CREATE TABLE statement, Primary/Foreign key constraints
Problem 1:
Create the following table:
-
Table name: customer
-
Columns:
-
customerID (whole number max 4 digits)
-
-
customerName (variable character max 50 characters) o customerSince (date)
-
-
Primary key on column customerID named customer_pk
Problem 2:
Execute the following two statements (inserting one sample record into table customer and verifying that record was correctly inserted):
-
INSERT INTO customer VALUES(1008, ‘New Customer’, sysdate);
-
SELECT * FROM customer;
Problem 3:
Create a second table:
-
Table name: orders
-
Columns:
-
-
orderID (whole number max 8 digits) o orderDate (date)
-
o shippingMethod (variable character max 25 characters) o customerID (whole number max 4 digits)
-
Primary key on column orderID named orderID_pk
-
Foreign key on column customerID relating to column customerID in table customer named customerid_fk
Problem 4:
Execute the following statements:
-
INSERT INTO orders VALUES(12345678, sysdate, ‘2-Day’, 1008);
-
INSERT INTO orders VALUES(88888888, sysdate, ‘2-Day’, 1009);
-
SELECT * FROM orders;
Problem 5:
Explain why the second INSERT statement under 4. failed with an error (No screenshot needed, simply a written answer).