daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest Oct 23rd, 2018 62 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. CREATE DATABASE LibraryManagement
  2. GO
  3.  
  4. USE LibraryManagement
  5. GO
  6.  
  7. CREATE TABLE Author
  8. (
  9.     Id INT NOT NULL IDENTITY PRIMARY KEY,
  10.     AuthorName NVARCHAR(100) UNIQUE NOT NULL,
  11. )
  12. GO
  13.  
  14. CREATE TABLE Publisher
  15. (
  16.     Id INT NOT NULL IDENTITY PRIMARY KEY,
  17.     PublisherName NVARCHAR(100) NOT NULL UNIQUE,
  18. )
  19. GO
  20.  
  21. CREATE TABLE Category
  22. (
  23.     Id INT NOT NULL IDENTITY PRIMARY KEY,
  24.     CategoryName NVARCHAR(100) NOT NULL UNIQUE,
  25. )
  26. GO
  27.  
  28. CREATE TABLE Book
  29. (
  30.     Id INT NOT NULL IDENTITY PRIMARY KEY,
  31.     ISBN VARCHAR(30),
  32.     Title NTEXT NOT NULL,
  33.     PublishedYear INT,
  34.     BookDecription NTEXT,
  35.     AuthorId INT,
  36.     PublisherId INT,
  37.     CategoryId INT,
  38.     Quantity INT,
  39.  
  40.     FOREIGN KEY (PublisherId) REFERENCES dbo.Publisher(Id),
  41.     FOREIGN KEY (AuthorId) REFERENCES dbo.Author(Id),
  42.     FOREIGN KEY (CategoryId) REFERENCES dbo.Category(Id),
  43. )
  44. GO
  45.  
  46. CREATE TABLE Student
  47. (
  48.     Id INT NOT NULL IDENTITY PRIMARY KEY,
  49.     StudentId VARCHAR(10) NOT NULL,
  50.     StudentName NTEXT NOT NULL,
  51.     Birthday DATE,
  52.     PersonalId VARCHAR(12),
  53.     PasswordStr VARCHAR(MAX),
  54. )
  55. GO
  56.  
  57. CREATE TABLE LibManager
  58. (
  59.     Id INT NOT NULL IDENTITY PRIMARY KEY,
  60.     Username VARCHAR(20),
  61.     ManagerName NTEXT,
  62.     PersonalId VARCHAR(12),
  63.     Birthday DATE,
  64.     PasswordStr VARCHAR(MAX),
  65. )
  66. GO
  67.  
  68. CREATE TABLE BookLending
  69. (
  70.     Id INT NOT NULL IDENTITY PRIMARY KEY,
  71.     BooIdOne INT NOT NULL,
  72.     BookIdTwo INT,
  73.     StudentId INT NOT NULL,
  74.     LendingDay DATE,
  75.     IsReturn BIT DEFAULT 0,
  76.     LendingManagerId INT NOT NULL,
  77.     ReturnManagerId INT,
  78.  
  79.     FOREIGN KEY (BooIdOne) REFERENCES dbo.Book(Id),
  80.     FOREIGN KEY (BookIdTwo) REFERENCES dbo.Book(Id),
  81.     FOREIGN KEY (StudentId) REFERENCES dbo.Student(Id),
  82.     FOREIGN KEY (LendingManagerId) REFERENCES dbo.LibManager(Id),
  83.     FOREIGN KEY (ReturnManagerId) REFERENCES dbo.LibManager(Id)
  84. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Pastebin PRO 'BLACK FRIDAY SPECIAL'!
Get 60% OFF Pastebin PRO accounts!
 
Top