Advertisement
Guest User

Untitled

a guest
May 24th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. CREATE TABLE Category (
  2. CategoryId int IDENTITY(1,1) PRIMARY KEY,
  3. CategoryName varchar(255) NOT NULL
  4. );
  5.  
  6. CREATE TABLE Book (
  7. BookId int IDENTITY(1,1) PRIMARY KEY,
  8. BookName varchar(255) NOT NULL,
  9. CategoryId int FOREIGN KEY REFERENCES Category(CategoryId),
  10. Available bit NOT NULL DEFAULT 1
  11. );
  12.  
  13. CREATE TABLE Client (
  14. ClientId int IDENTITY(1,1) PRIMARY KEY,
  15. ClientFullName varchar(255) NOT NULL,
  16. IdentityCard varchar(255) NOT NULL
  17. );
  18.  
  19. CREATE TABLE Rent (
  20. RentId int IDENTITY(1,1) PRIMARY KEY,
  21. BookId int FOREIGN KEY REFERENCES Book(BookId),
  22. ClientId int FOREIGN KEY REFERENCES Client(ClientId),
  23. RentalDate datetime NOT NULL DEFAULT getdate(),
  24. Returned bit NOT NULL DEFAULT 0
  25. );
  26.  
  27.  
  28. Insert into Category (CategoryName) values ('Cooking')
  29. Insert into Category (CategoryName) values ('Mystery & Thriller')
  30. Insert into Category (CategoryName) values ('Business')
  31.  
  32. Insert into Book (BookName, CategoryId) values ('Cooking Light', 1)
  33. Insert into Book (BookName, CategoryId) values ('Prophecy', 2)
  34. Insert into Book (BookName, CategoryId) values ('Shift', 3)
  35. Insert into Book (BookName, CategoryId) values ('The Confession', 2)
  36.  
  37. Insert Client (ClientFullName, IdentityCard) values ('Freddy Krueger', '8776655M')
  38. Insert Client (ClientFullName, IdentityCard) values ('Tony Montana', '3355665M')
  39. Insert Client (ClientFullName, IdentityCard) values ('Jamie Oliver', '7775433A')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement