Advertisement
ralitsa_d

Create Tables

Oct 14th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 0.78 KB | None | 0 0
  1. span class="re5"> CREATE TABLE DepositsTypes(
  2.     DepositTypeId IT PRIMARY KEY,
  3.     Name VARCHAR(50)
  4. )
  5.  
  6. CREATE TABLE Deposits(
  7.     DepositID INT PRIMARY KEY IDENTITY,
  8.     Amount DECIMAL (10, 2),
  9.     StartDate DATE,
  10.     EndDate DATE,
  11.     DepositTypeId INT,
  12.     CustomerID INt,
  13.     CONSTRAINT FK_Deposits_DeposistsTypes FOREIGN KEY (DepositTypeId)
  14.     REFERENCES DepositTypes(DepositTypeId),
  15.     CONSTRAINT FK_Deposits_Customers FOREIGN KEY(CustomerId)
  16.     REFERENCES Customers(CustomerId)
  17. )
  18.  
  19. CREATE TABLE EmployeesDeposits(
  20.     EmployeeID INT,
  21.     DepositID INT,
  22.     CONSTRAINT PK_EmployeesDeposits PRIMARY KEY (EmployeeID, DepositID),
  23.     CONSTRAINT FK_EmployeesDeposits_Employees FOREIGN KEY (EmployeeID)
  24.     REFERENCES Employees(EmployeeID),
  25.     CONSTRAINT FK_EmployeesDeposits_Deposits FOREIGN KEY (DepositID)
  26.     REFERENCES Deposits(DepositID)
  27. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement