Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.90 KB | None | 0 0
  1. IF DB_ID('LibraryDatabase') IS NOT NULL
  2. DROP DATABASE LibraryDatabase
  3.  
  4. CREATE DATABASE LibraryDatabase
  5. GO
  6.  
  7. USE [LibraryDatabase]
  8.  
  9. GO
  10. /****** Object: Table [dbo].[Customers] Script Date: 1/31/2015 1:48:56 PM ******/
  11. SET ANSI_NULLS ON
  12. GO
  13. SET QUOTED_IDENTIFIER ON
  14. GO
  15. CREATE TABLE [dbo].[Publisher](
  16. [PublisherName] [varchar](30) NOT NULL,
  17. [PublisherAddress] [varchar](50) NOT NULL,
  18. [PublisherPhone] [varchar](14) NOT NULL,
  19. CONSTRAINT [PK_Publishers] PRIMARY KEY CLUSTERED
  20. (
  21. [PublisherName] ASC
  22. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  23. ) ON [PRIMARY]
  24.  
  25. GO
  26. /****** Object: Table [dbo].[Librarian] Script Date: 1/31/2015 1:48:56 PM ******/
  27. SET ANSI_NULLS ON
  28. GO
  29. SET QUOTED_IDENTIFIER ON
  30. GO
  31. CREATE TABLE [dbo].[Librarian](
  32. [LibrarianID] [char](10) NOT NULL,
  33. [LibrarianName] [varchar](25) NOT NULL,
  34. [LibrarianHireDate] [date] Default (getdate()) NOT NULL,
  35. [LibrarianSalary] [int] DEFAULT 0 NOT NULL,
  36. CONSTRAINT [PK_Librarian] PRIMARY KEY CLUSTERED
  37. (
  38. [LibrarianID] ASC
  39. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  40. ) ON [PRIMARY]
  41.  
  42. GO
  43. /****** Object: Table [dbo].[Users] Script Date: 1/31/2015 1:48:56 PM ******/
  44. SET ANSI_NULLS ON
  45. GO
  46. SET QUOTED_IDENTIFIER ON
  47. GO
  48. CREATE TABLE [dbo].[Users](
  49. [UserID] [char](10) NOT NULL,
  50. [UserName] [varchar](25) NULL,
  51. [UserAge] [char](3) NULL,
  52. [UserJoinDate] [date] Default (getdate()) NOT NULL,
  53. [LateFees] [decimal](19, 2) DEFAULT 0.00 NOT NULL,
  54. CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED
  55. (
  56. [UserID] ASC
  57. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  58. ) ON [PRIMARY]
  59.  
  60. GO
  61. /****** Object: Table [dbo].[Book] Script Date: 1/31/2015 1:48:56 PM ******/
  62. SET ANSI_NULLS ON
  63. GO
  64. SET QUOTED_IDENTIFIER ON
  65. GO
  66. CREATE TABLE [dbo].[Book](
  67. [Barcode] [char](15) NOT NULL,
  68. [Title] [varchar](250) NULL,
  69. [Author] [varchar](25) NULL,
  70. [DDC] [varchar](15) NOT NULL,
  71. [Genre] [varchar](20) NULL,
  72. [CoverType] [varchar](15) NULL,
  73. [Condition] [varchar](15) DEFAULT 'Excellent',
  74. [ISBN] [varchar](20) NOT NULL,
  75. [Summary] [varchar](4000) NULL,
  76. [PublisherName] [varchar](30) NOT NULL,
  77. [PublisherDate] [date] NULL,
  78. [Value] DECIMAL(7,2) DEFAULT 0.00,
  79. CONSTRAINT [PK_Incidents] PRIMARY KEY CLUSTERED
  80. (
  81. [Barcode] ASC
  82. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  83. ) ON [PRIMARY]
  84. alter table book
  85. ADD CONSTRAINT [FK_Book] FOREIGN KEY (PublisherName)
  86. REFERENCES Publisher (PublisherName)
  87.  
  88. GO
  89. /****** Object: Table [dbo].[Hold] Script Date: 1/31/2015 1:48:56 PM ******/
  90. SET ANSI_NULLS ON
  91. GO
  92. SET QUOTED_IDENTIFIER ON
  93. GO
  94. CREATE TABLE [dbo].[Hold](
  95. [HoldID] [char](10) NOT NULL,
  96. [Barcode] [char](15) NOT NULL,
  97. [UserID] [char](10) NOT NULL,
  98. CONSTRAINT [PK_Hold] PRIMARY KEY CLUSTERED
  99. (
  100. [holdID] ASC
  101. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  102. ) ON [PRIMARY]
  103. alter table Hold
  104. ADD CONSTRAINT [FK_Hold1] FOREIGN KEY (Barcode)
  105. REFERENCES Book (Barcode)
  106. alter table Hold
  107. ADD CONSTRAINT [FK_Hold2] FOREIGN KEY (UserID)
  108. REFERENCES Users (UserID)
  109.  
  110. GO
  111. /****** Object: Table [dbo].[Checkout] Script Date: 1/31/2015 1:48:56 PM ******/
  112. SET ANSI_NULLS ON
  113. GO
  114. SET QUOTED_IDENTIFIER ON
  115. GO
  116. CREATE TABLE [dbo].[Checkout](
  117. [CheckoutID] [char](10) NOT NULL,
  118. [Barcode] [char](15) NOT NULL,
  119. [UserID] [char](10) NOT NULL,
  120. [CheckoutDate] [date] Default (getdate()) NOT NULL,
  121. [ReturnDate] [date] NULL,
  122. [LibrarianID] [char](10) NOT NULL,
  123. CONSTRAINT [PK_Checkout] PRIMARY KEY CLUSTERED
  124. (
  125. [CheckoutID] ASC
  126. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  127. ) ON [PRIMARY]
  128. alter table Checkout
  129. ADD CONSTRAINT [FK_Checkout1] FOREIGN KEY (LibrarianID)
  130. REFERENCES Librarian (LibrarianID)
  131. alter table Checkout
  132. ADD CONSTRAINT [FK_Checkout2] FOREIGN KEY (Barcode)
  133. REFERENCES Book (Barcode)
  134. alter table Checkout
  135. ADD CONSTRAINT [FK_Checkout3] FOREIGN KEY (UserID)
  136. REFERENCES Users (UserID)
  137.  
  138. INSERT INTO Publisher VALUES(
  139. 'Bruce Wayne', '1007 Mountain Drive Gotham, DC', '349-431-3201'
  140. );
  141. INSERT INTO Publisher VALUES(
  142. 'Clark Kent', '344 Clinton Street Krypton, DC', '231-321-5432'
  143. );
  144. INSERT INTO Publisher VALUES(
  145. 'Diana Prince', '1234 Space Street Themyscira DC', '341-302-4032'
  146. );
  147. INSERT INTO Publisher VALUES(
  148. 'Selina Kyle', '9000 Meow Ave Gotham DC', '548-302-4032'
  149. );
  150. INSERT INTO Publisher VALUES(
  151. 'Arthur Curry', '2525 Ocean Street Atlantis DC', '654-741-5285'
  152. );
  153. INSERT INTO Publisher VALUES(
  154. 'Stephen King', '1053 Atlantic Ave BC', '778-911-8594'
  155. );
  156. INSERT INTO Publisher VALUES(
  157. 'J.K. Rowling', '5492 Hogwarts Street CA', '123-543-7684'
  158. );
  159. INSERT INTO Publisher VALUES(
  160. 'Stephen Curry', '4123 Lakers Street CH', '435-123-3455'
  161. );
  162. INSERT INTO Publisher VALUES(
  163. 'Phoenix Wright', '9106 Objection Ave JP', '591-203-991'
  164. );
  165. INSERT INTO Publisher VALUES(
  166. 'Mona Pizza', '1234 Eiffel Crescent FR', '532-234-7265'
  167. );
  168. INSERT INTO Publisher VALUES(
  169. 'Rick Grimes', '2415 Prison Street US', '115-251-6774'
  170. );
  171. INSERT INTO Publisher VALUES(
  172. 'Michael Chung', '1563 Lodgepole Place CA', '778-239-3088'
  173. );
  174. INSERT INTO Publisher VALUES(
  175. 'Anderson Phan', '1234 BCIT Street CA', '125-452-5794'
  176. );
  177.  
  178.  
  179. INSERT INTO Librarian VALUES(
  180. 'L09', 'Emma Watson', '01/28/2005', '80000'
  181. );
  182. INSERT INTO Librarian VALUES(
  183. 'L42', 'Daniel Radcliffe', '09/21/2011', '65000'
  184. );
  185. INSERT INTO Librarian VALUES(
  186. 'L12', 'Rupert Grint', '03/24/2007', '73000'
  187. );
  188. INSERT INTO Librarian VALUES(
  189. 'L28', 'Alan Rickman', '05/02/2009', '67000'
  190. );
  191. INSERT INTO Librarian VALUES(
  192. 'L69', 'Tom Felton', '12/25/2005', '90001'
  193. );
  194. INSERT INTO Librarian VALUES(
  195. 'L58', 'Spider Man', '05/12/2004', '55000'
  196. );
  197. INSERT INTO Librarian VALUES(
  198. 'L87', 'Bat Man', '08/10/2002', '67000'
  199. );
  200. INSERT INTO Librarian VALUES(
  201. 'L39', 'Aqua Man', '09/19/2001', '92000'
  202. );
  203. INSERT INTO Librarian VALUES(
  204. 'L28', 'He Man', '11/15/2011', '22000'
  205. );
  206. INSERT INTO Librarian VALUES(
  207. 'L96', 'Michael Phelps', '03/03/2008', '82000'
  208. );
  209. INSERT INTO Librarian VALUES(
  210. 'L48', 'George Miyazaki', '09/19/2007', '19000'
  211. );
  212. INSERT INTO Librarian VALUES(
  213. 'L15', 'Lorie Kojima', '11/03/2001', '10000'
  214. );
  215. INSERT INTO Librarian VALUES(
  216. 'L15', 'Dylan James', '07/17/2004', '41000'
  217. );
  218.  
  219.  
  220.  
  221.  
  222. INSERT INTO Users VALUES(
  223. 'U3940', 'Tony stark', '38', '09/02/2005', '90.01'
  224. );
  225. INSERT INTO Users VALUES(
  226. 'U213', 'Steve Rogers', '120', '03/28/2014', '0.00'
  227. );
  228. INSERT INTO Users VALUES(
  229. 'U2456', 'Bruce Banner', '42', '06/17/2012', '3.45'
  230. );
  231. INSERT INTO Users VALUES(
  232. 'U9034', 'Stephen Strange', '29', '04/20/2010', '4.20'
  233. );
  234. INSERT INTO Users VALUES(
  235. 'U39', 'Carol Danvers', '21', '01/01/2007', '0.50'
  236. );
  237. INSERT INTO Users VALUES(
  238. 'U294', 'Carl Junior', '81', '02/02/2002', '3.50'
  239. );
  240. INSERT INTO Users VALUES(
  241. 'U28', 'Bruce Li', '35', '06/07/2001', '6.60'
  242. );
  243. INSERT INTO Users VALUES(
  244. 'U152', 'Chuck Nores', '24', '08/02/2006', '9.00'
  245. );
  246. INSERT INTO Users VALUES(
  247. 'U19', 'Kobe Burlake', '32', '06/10/2012', '6.14'
  248. );
  249. INSERT INTO Users VALUES(
  250. 'U18', 'Yoshi Yamaguchi', '12', '03/21/2011', '4.50'
  251. );
  252. INSERT INTO Users VALUES(
  253. 'U32', 'Luigi Fettucini', '21', '09/23/2004', '0.00'
  254. );
  255. INSERT INTO Users VALUES(
  256. 'U4313', 'Mario Broderos', '17', '11/22/2014', '9.12'
  257. );
  258. INSERT INTO Users VALUES(
  259. 'U123', 'Bowser Stallone', '11', '08/22/2005', '8.45'
  260. );
  261.  
  262.  
  263.  
  264. INSERT INTO Book VALUES(
  265. 'B9408', 'Inception: Subquery Within a Subquery', 'Luke Skywalker', '52043.34248',
  266.  
  267. 'Fantasy', 'Paperback', 'Rekted', '978-3-16-148410-0', 'Database management 10th edition',
  268.  
  269. 'Bruce Wayne', '01/23/2013', '49.95'
  270. );
  271. INSERT INTO book VALUES(
  272. 'B44', 'War: Star Trek', 'Obi-Wan', '21389.4323', 'Comedy', 'Hardcover', 'Torn', '978-6
  273.  
  274. -09-349833-0', 'Ha haha get the title? Star wars and star trek hue hue please don’t
  275.  
  276. flame', 'Clark Kent', '09/23/2009', '69.99'
  277. );
  278. INSERT INTO book VALUES(
  279. 'B234', 'Force: The Awakening', 'Yoda', '12312.45389', 'Science Fiction', 'Softcover',
  280.  
  281. 'Alright', '978-9-12-694823-0', 'Luke stumbles across his long lost father and awakens the
  282.  
  283. force within him', 'Diana Prince', '12/21/2014', '29.95'
  284. );
  285. INSERT INTO book VALUES(
  286. 'B898', 'Jedi: The Returning Wars', 'Anakin Skywalker', '34280.54375', 'Romance',
  287.  
  288. 'Hardcover', 'Pages Missing', '978-3-21-298311-0', 'After going on a journey, Ash Ketchum
  289.  
  290. finally returns to Pallet Town and marries Misty.', 'Selina Kyle', '02/14/2005', '35.00'
  291. );
  292. INSERT INTO book VALUES(
  293. 'B12093', 'Cloning Wars', 'Mace Windu', '43286.43249', 'Science Fiction', 'Ebook',
  294.  
  295. 'Excellent', '978-0-13-934893-0', 'Harry Potter may think he actually killed Lord
  296.  
  297. Voldemort but truth is, Voldemort made plenty of clones of himself scattered throughout
  298.  
  299. the wizardry world.', 'Arthur Curry', '12/25/2008', '0.01'
  300. );
  301. INSERT INTO book VALUES(
  302. 'B1328', 'It', 'Stephen King', '93247.83249', 'Horror', 'Ebook',
  303.  
  304. 'Excellent', '234-2-49-123890-0', 'Follows a group of children who are haunted by an evil apparition that takes form of a clown.',
  305. 'Penguin Publishers', '11/12/2001', '11.00'
  306. );
  307. INSERT INTO book VALUES(
  308. 'B2346', 'A Brief History of Time', 'Stephen Hawking', '93892.12789', 'Science', 'Hardcover',
  309.  
  310. 'Excellent', '144-0-84-23178-0', 'Told in language we all can understand, A Brief History of Time plunges into the exotic realms of black holes and quarks, of antimatter and “arrows of time,” of the big bang and a bigger God—where the possibilities are wondrous and unexpected. With exciting images and profound imagination, Stephen Hawking brings us closer to the ultimate secrets at the very heart of creation.'
  311. , 'Stephen Hawking', '01/1/2002', '6.10'
  312. );
  313. INSERT INTO book VALUES(
  314. 'B23484', 'A Series of Unfortunate Events', 'Lemony Snicket', '12435.231970', 'Science Fiction', 'Softcopy',
  315.  
  316. 'Excellent', '346-5-68-98137-0', 'Are you made fainthearted by death? Does fire unnerve you? Is a villain something that might crop up in future nightmares of yours? Are you thrilled by nefarious plots? Is cold porridge upsetting to you? Vicious threats? Hooks? Uncomfortable clothing?',
  317. 'Brett Helquist', '06/08/2007', '8.15'
  318. );
  319. INSERT INTO book VALUES(
  320. 'B43289', 'Catch-22: 50th Anniversary Edition', 'Joseph Heller', '05348.21834', 'History', 'Softcopy',
  321.  
  322. 'Scratched', '545-1-39-34879-0', 'Set in Italy during World War II, this is the story of the incomparable, malingering bombardier, Yossarian, a hero who is furious because thousands of people he has never met are trying to kill him. But his real problem is not the enemy—it is his own army, which keeps increasing the number of missions the men must fly to complete their service.',
  323. 'Christopher Buckley', '02/15/2011', '10.52'
  324. );
  325. INSERT INTO book VALUES(
  326. 'B23498', 'Charlie and the Chocolate Factory', 'Roald Dahl', '34654.08432', 'Science Fiction', 'Hardcopy',
  327.  
  328. 'Fifty years ago, Roald Dahl created a world that captured the imagination of millions of readers, and a boy who captured their hearts. Now featuring an introduction by award-winning author Jon Scieszka, this special edition of Charlie and the Chocolate Factory is perfect for longtime Roald Dahl fans, or for any reader discovering him for the very first time.',
  329. 'Quentin Blake', '11/29/2010', '11.55'
  330. );
  331. INSERT INTO book VALUES(
  332. 'B34983', 'Fahrenheit 451: A Novel', 'Ray Bradbury', '63525.23465', 'Crime', 'Hardcopy',
  333.  
  334. 'Guy Montag is a fireman. In his world, where television rules and literature is on the brink of extinction, firemen start fires rather than put them out. His job is to destroy the most illegal of commodities, the printed book, along with the houses in which they are hidden.',
  335. 'Quentin Blake', '11/15/2005', '9.15'
  336. );
  337. INSERT INTO book VALUES(
  338. 'B2390', 'Of Human Bondage', 'W. Somerset Maugham', '35263.98789', 'Drama', 'Softcopy',
  339.  
  340. 'The first and most autobiographical of Maughams masterpieces. It is the story of Philip Carey, an orphan eager for life, love and adventure. After a few months studying in Heidelberg, and a brief spell in Paris as a would-be artist, he settles in London to train as a doctor where he meets Mildred, the loud but irresistible waitress with whom he plunges into a tortured and masochistic affair.',
  341. 'Jane Smiley', '06/14/2014', '2.14'
  342. );
  343. INSERT INTO book VALUES(
  344. 'B23473', 'Persepolis: The Story of a Childhood', 'Marjane Satrapi', '65288.46896', 'Graphic Novel', 'Hardcopy',
  345.  
  346. 'In powerful black-and-white comic strip images, Satrapi tells the story of her life in Tehran from ages six to fourteen, years that saw the overthrow of the Shah’s regime, the triumph of the Islamic Revolution, and the devastating effects of war with Iraq. The intelligent and outspoken only child of committed Marxists and the great-granddaughter of one of Iran’s last emperors, Marjane bears witness to a childhood uniquely entwined with the history of her country.',
  347. 'Jane Smiley', '02/12/2004', '9.44'
  348. );
  349.  
  350.  
  351.  
  352. INSERT INTO Hold VALUES(
  353. 'H123', 'B9408', 'U3940'
  354. );
  355. INSERT INTO Hold VALUES(
  356. 'H3492', 'B44', 'U213'
  357. );
  358. INSERT INTO Hold VALUES(
  359. 'H2913', 'B234', 'U39'
  360. );
  361. INSERT INTO Hold VALUES(
  362. 'H39408', 'B898', 'U9034'
  363. );
  364. INSERT INTO Hold VALUES(
  365. 'H30483', 'B12093', 'U2456'
  366. );
  367. INSERT INTO Hold VALUES(
  368. 'H5326', 'B19342', 'U8952'
  369. );
  370. INSERT INTO Hold VALUES(
  371. 'H5823', 'B90344', 'U4098'
  372. );
  373. INSERT INTO Hold VALUES(
  374. 'H54678', 'B79049', 'U3290'
  375. );
  376. INSERT INTO Hold VALUES(
  377. 'H34840', 'B60937', 'U1129'
  378. );
  379. INSERT INTO Hold VALUES(
  380. 'H10428', 'B65498', 'U4328'
  381. );
  382. INSERT INTO Hold VALUES(
  383. 'H95823', 'B56408', 'U0984'
  384. );
  385. INSERT INTO Hold VALUES(
  386. 'H34689', 'B25395', 'U3258'
  387. );
  388. INSERT INTO Hold VALUES(
  389. 'H2398', 'B59056', 'U2398'
  390. );
  391.  
  392.  
  393. INSERT INTO Checkout VALUES(
  394. 'C95454', 'B9408', 'U3940', '09/28/2014', '', 'L42'
  395. );
  396. INSERT INTO Checkout VALUES(
  397. 'C49380', 'B44', 'U213', '05/14/2014', '05/23/2013', 'L12'
  398. );
  399. INSERT INTO Checkout VALUES(
  400. 'C8574', 'B234', 'U39', '06/24/2008', '09/30/2008', 'L42'
  401. );
  402. INSERT INTO Checkout VALUES(
  403. 'C324', 'B898', 'U9034', '01/21/2011', '02/03/2011', 'L28'
  404. );
  405. INSERT INTO Checkout VALUES(
  406. 'C63847', 'B12093', 'U2456', '12/27/2013', '07/07/2014', 'L09'
  407. );
  408. INSERT INTO Checkout VALUES(
  409. 'C34879', 'B68092', 'U4892', '03/22/2012', '03/24/2012', 'L39'
  410. );
  411. INSERT INTO Checkout VALUES(
  412. 'C43289', 'B69022', 'U3248', '02/18/2002', '07/04/2002', 'L34'
  413. );
  414. INSERT INTO Checkout VALUES(
  415. 'C32489', 'B09532', 'U3548', '11/24/2001', '10/03/2004', 'L28'
  416. );
  417. INSERT INTO Checkout VALUES(
  418. 'C43298', 'B54893', 'U1024', '01/01/2001', '08/08/2007', 'L09'
  419. );
  420. INSERT INTO Checkout VALUES(
  421. 'C34298', 'B46980', 'U3948', '06/02/2012', '07/24/2012', 'L58'
  422. );
  423. INSERT INTO Checkout VALUES(
  424. 'C43298', 'B54893', 'U1024', '05/16/2009', '01/30/2010', 'L84'
  425. );
  426. INSERT INTO Checkout VALUES(
  427. 'C23495', 'B89032', 'U4059', '08/12/2013', '09/24/2013', 'L26'
  428. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement