Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE Customers
- (CustomerID int AUTO_INCREMENT,
- CompanyName varchar(100),
- ContactName varchar(100),
- ContactTitle varchar(100),
- Adress varchar(400),
- City varchar(30),
- Region varchar(30),
- PostalCode smallint,
- Country varchar(30),
- Phone smallint,
- Fax smallint,
- CONSTRAINT c_Customers_PK PRIMARY KEY(CustomerID));
- CREATE TABLE Orders
- (OrderID int AUTO_INCREMENT,
- CustomerID int,
- EmployeeID int,
- OrderDate date,
- RequiredDate date,
- ShipDate date,
- ShipName varchar(50),
- ShipAdress varchar(100),
- ShipCity varchar(39),
- ShipRegion varchar(39),
- ShipCountry varchar(20));
- alter table Orders add CONSTRAINT c_Orders_PK PRIMARY KEY(OrderID),
- alter table Orders add CONSTRAINT c_Orders_FK FOREIGN KEY(CustomerID) REFERENCES Customers(CustomerID);
- alter table Orders add CONSTRAINT c_Orders_FK_EmployeeID FOREIGN KEY(EmployeeID) REFERENCES employees(EmployeeID);
- CREATE TABLE Products
- (ProductID int AUTO_INCREMENT,
- ProductName varchar(50),
- SupplierID int,
- CategoryID int,
- UnitPrice double,
- CONSTRAINT c_Products_PK PRIMARY KEY(ProductID));
- alter table Products add CONSTRAINT c_Products_CategoryID FOREIGN KEY(CategoryID) REFERENCES Categories(CategoryID);
- alter table Products add CONSTRAINT c_Products_SupplierID FOREIGN KEY(SupplierID) REFERENCES Suppliers(SupplierID);
- create table Order_Details
- (OrderID int,
- ProductID int,
- UnitPrice float,
- Quantity smallint,
- Discount decimal);
- alter table Order_Details add CONSTRAINT c_Order_Product_FK FOREIGN KEY(ProductID) REFERENCES Products(ProductID);
- alter table Order_Details add CONSTRAINT c_Order_Order_FK FOREIGN KEY(OrderID) REFERENCES Orders(OrderID);
- create table Categories
- (CategoryID int AUTO_INCREMENT,
- CategoryName varchar(50),
- Description varchar(250),
- CONSTRAINT c_Categories_PK PRIMARY KEY(CategoryID));
- create table Employees
- (EmployeeID int AUTO_INCREMENT,
- LastName varchar(30),
- FirstName varchar(30),
- Title varchar(30),
- TitleOfCourtsey varchar(30),
- BirthDate date,
- HireDate date,
- Adress text,
- City varchar(41),
- Region varchar(41),
- PostalCode smallint,
- Country varchar(30),
- HomePhone smallint,
- ReportsTo int REFERENCES Employees(EmployeeID),
- Salary decimal,
- CONSTRAINT c_Employees_PK PRIMARY KEY (EmployeeID));
- alter table Employees add CONSTRAINT c_Rddasd FOREIGN KEY(ReportsTo) REFERENCES Employees(EmployeeID);
- create table OrderDetails
- (OrderID int,
- ProductID int,
- UnitPrice int,
- Quantity int,
- Discount decimal);
- ALTER table OrderDetails add CONSTRAINT c_Order_FK FOREIGN KEY(OrderID) REFERENCES Orders(OrderID);
- ALTER table orderdetails add CONSTRAINT c_Product_FK FOREIGN KEY(ProductID) REFERENCES Products(ProductID);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement