Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 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 INTEGER UNSIGNED 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 VALUES (1, "Big Booty", 23.94);
  26. INSERT INTO Discs VALUES (2, "Empires", 40.00);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement