Advertisement
Guest User

Code

a guest
Feb 22nd, 2018
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.17 KB | None | 0 0
  1. DROP DATABASE if exists petespaintWO;
  2.  
  3. CREATE DATABASE petespaintWO;
  4.  
  5. USE petespaintWO;
  6.  
  7. DROP TABLE if exists customer;
  8.  
  9. CREATE TABLE customer (
  10. custId INT NOT NULL AUTO_INCREMENT,
  11. first VARCHAR( 30 ) NOT NULL,
  12. last VARCHAR( 30 ) NOT NULL,
  13. email VARCHAR( 50 ) UNIQUE NOT NULL,
  14. constraint custid_pk primary key (custId),
  15. CONSTRAINT CHECK (email LIKE '%@%')
  16. ) ENGINE = InnoDB;
  17.  
  18. DROP TABLE if exists quote;
  19.  
  20. CREATE Table quote(
  21. quoteId INT NOT NULL AUTO_INCREMENT,
  22. custId INT NOT NULL,
  23. typeJob VARCHAR( 50 ) NOT NULL ,
  24. typePaint VARCHAR( 50 ) NOT NULL ,
  25. color VARCHAR( 50 ) NOT NULL ,
  26. time INT NOT NULL,
  27. gallons INT NOT NULL,
  28. area INT NOT NULL,
  29. totalCost decimal(10,2) NOT NULL,
  30. constraint quoteId_pk primary key (quoteId),
  31. constraint custId_fk foreign key (custId) references customer(custId)
  32. ) ENGINE = InnoDB;
  33.  
  34. DROP TABLE if exists wall;
  35.  
  36. CREATE TABLE wall(
  37. wallId INT NOT NULL AUTO_INCREMENT,
  38. quoteId INT NOT NULL,
  39. length INT NOT NULL,
  40. width INT NOT NULL,
  41. constraint wallId_pk primary key (wallId),
  42. constraint quoteId_fk foreign key (quoteId) references quote(quoteId),
  43. CONSTRAINT CHECK (length>0),
  44. CONSTRAINT CHECK (width>0)
  45. ) ENGINE = InnoDB;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement