[sql] Shop111

Viewer

  1. CREATE DATABASE `shop111`;
  2. USE shop111;
  3.  
  4.  
  5. CREATE TABLE postavschik(id post INT NOT NULL PRIMARY KEY, contacts INT NOT NULL, adress VARCHAR(50) NOT NULL, specialization VARCHAR(50) NOT NULL);
  6. CREATE TABLE shop(id_shop INT NOT NULL PRIMARY KEY, name VARCHAR(50) NOT NULL, phonenumber VARCHAR(50) NOT NULL,  specialization VARCHAR(50) NOT NULL, ownership VARCHAR(20) NOT NULL, worktime INT NOT NULL,postID INT NOT NULL, FOREIGN KEY (postID) REFERENCES postavschik (id_post));
  7. CREATE TABLE tovar(id_tovar INT NOT NULL PRIMARY KEY, price INT NOT NULL, TYPE VARCHAR(50) NOT NULL, expirationdate DATE NOT NULL, amount INT NOT NULL, creator VARCHAR(50) NOT NULL, shopID INT NOT NULL, FOREIGN KEY (shopID) REFERENCES shop(id_shop));
  8. CREATE TABLE sotrudniki(id_sot INT NOT NULL PRIMARY KEY, fullname VARCHAR(50) NOT NULL, post VARCHAR(50) NOT NULL, phonenumber VARCHAR(50) NOT NULL, shopID INT NOT NULL, FOREIGN KEY (shopID) REFERENCES shop(id_shop));
  9. CREATE TABLE pokupatel(id_pok INT NOT NULL PRIMARY KEY, fullname VARCHAR(50) NOT NULL, phonenumber VARCHAR(50) NOT NULL, yearofbirth DATE NOT NULL);
  10. CREATE TABLE checks(id_check INT NOT NULL PRIMARY KEY, tovarID INT NOT NULL,pokID INT NOT NULL, sotID INT NOT NULL, shopID INT NOT NULL, FOREIGN KEY (tovarID) REFERENCES tovar (id_tovar), FOREIGN KEY (pokID   ) REFERENCES pokupatel (id_pok), FOREIGN KEY (sotID) REFERENCES sotrudniki (id_sot), FOREIGN KEY (shopID) REFERENCES shop(id_shop));
  11.  
  12.  
  13.  

Editor

You can edit this paste and save as new:


File Description
  • Shop111
  • Paste Code
  • 02 Dec-2022
  • 1.41 Kb
You can Share it: