daily pastebin goal
76%
SHARE
TWEET

Untitled

a guest May 16th, 2018 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE Product (
  2. "Product_id" int,
  3. "Stock_quantity" int,
  4. "Product_name" varchar(50),
  5. "Model" varchar(50),
  6. "Average_rating" float(3),
  7. "RAM" int,
  8. "Color" varchar(20),
  9. "Price" float(10),
  10. PRIMARY KEY ("Product_id")
  11. );
  12.  
  13. CREATE TABLE Sale (
  14. "Sale_id" int,
  15. "Sale_date" date,
  16. "Employee_id" int,
  17. "Customer_id" int,
  18. "Product_id" int,
  19. "Product_quantity" int,
  20. "Rating" int,
  21. PRIMARY KEY ("Sale_id"),
  22. FOREIGN KEY("Employee_id") REFERENCES Employee("Employee_id") ,
  23. FOREIGN KEY("Customer_id") REFERENCES Customer("Customer_id") ,
  24. FOREIGN KEY("Product_id") REFERENCES Product("Product_id")
  25. );
  26.  
  27.  
  28. CREATE TABLE Computer (
  29. "Type" varchar(10),
  30. "Processor" varchar(20),
  31. "Monitor_size" int
  32. )  inherits(Product);
  33.  
  34. CREATE TABLE Mobile (
  35. "Os" varchar(30),
  36. "Screen_size" int
  37.  ) inherits(Product);
  38.    
  39. ERROR: insert or update on table "sale" violates foreign key constraint "PK_Product_id"
  40. SQL state: 23503
  41. Detail: Key (Product_id)=(12) is not present in table "product".
RAW Paste Data
Top