Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. DROP DATABASE IF EXISTS store;
  2. CREATE DATABASE store;
  3. USE store;
  4.  
  5. CREATE TABLE Discs (
  6. DiscId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  7. Album VARCHAR(255) NOT NULL,
  8. Price FLOAT(3,2) NOT NULL,
  9. PRIMARY KEY (DiscID)
  10. );
  11.  
  12. CREATE TABLE Customers (
  13. CustomerId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  14. Name VARCHAR(255) NOT NULL,
  15. Album VARCHAR(255) NOT NULL,
  16. Copies INTEGER,
  17. PRIMARY KEY (CustomerId),
  18. CONSTRAINT FKC1
  19. FOREIGN KEY FKalbum (Album)
  20. REFERENCES Discs (DiscID)
  21. ON DELETE CASCADE
  22. ON UPDATE CASCADE
  23. );
  24.  
  25. INSERT INTO Discs (Album, Price) VALUES ("Big Booty", 23.94);
  26. INSERT INTO Discs (Album, Price) VALUES ("Empires", 40.00);
  27. INSERT INTO Customers (Name, Album, Copies) VALUES ("Joe", "motown", 12)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement