Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.20 KB | None | 0 0
  1. /*==============================================================*/
  2. /* DBMS name: Microsoft SQL Server 2012 */
  3. /* Created on: 06.12.2017 13:04:49 */
  4. /*==============================================================*/
  5.  
  6.  
  7. /*==============================================================*/
  8. /* Table: ADRES */
  9. /*==============================================================*/
  10. create table ADRES (
  11. ID_ADRES int not null,
  12. MIASTO varchar(50) not null,
  13. KOD_POCZTOWY varchar(0) not null,
  14. ULICA varchar(70) not null,
  15. NR varchar(15) not null,
  16. constraint PK_ADRES primary key nonclustered (ID_ADRES)
  17. )
  18. go
  19.  
  20. if exists (select 1 from sys.extended_properties
  21. where major_id = object_id('ADRES') and minor_id = 0)
  22. begin
  23. declare @CurrentUser sysname
  24. select @CurrentUser = user_name()
  25. execute sp_dropextendedproperty 'MS_Description',
  26. 'user', @CurrentUser, 'table', 'ADRES'
  27.  
  28. end
  29.  
  30.  
  31. select @CurrentUser = user_name()
  32. execute sp_addextendedproperty 'MS_Description',
  33. 'adres osoby
  34. ',
  35. 'user', @CurrentUser, 'table', 'ADRES'
  36. go
  37.  
  38. if exists(select 1 from sys.extended_properties p where
  39. p.major_id = object_id('ADRES')
  40. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_ADRES')
  41. )
  42. begin
  43. declare @CurrentUser sysname
  44. select @CurrentUser = user_name()
  45. execute sp_dropextendedproperty 'MS_Description',
  46. 'user', @CurrentUser, 'table', 'ADRES', 'column', 'ID_ADRES'
  47.  
  48. end
  49.  
  50.  
  51. select @CurrentUser = user_name()
  52. execute sp_addextendedproperty 'MS_Description',
  53. 'ID_ADRES',
  54. 'user', @CurrentUser, 'table', 'ADRES', 'column', 'ID_ADRES'
  55. go
  56.  
  57. if exists(select 1 from sys.extended_properties p where
  58. p.major_id = object_id('ADRES')
  59. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'MIASTO')
  60. )
  61. begin
  62. declare @CurrentUser sysname
  63. select @CurrentUser = user_name()
  64. execute sp_dropextendedproperty 'MS_Description',
  65. 'user', @CurrentUser, 'table', 'ADRES', 'column', 'MIASTO'
  66.  
  67. end
  68.  
  69.  
  70. select @CurrentUser = user_name()
  71. execute sp_addextendedproperty 'MS_Description',
  72. 'miasto w jakim mieszka dana osoba',
  73. 'user', @CurrentUser, 'table', 'ADRES', 'column', 'MIASTO'
  74. go
  75.  
  76. if exists(select 1 from sys.extended_properties p where
  77. p.major_id = object_id('ADRES')
  78. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'KOD_POCZTOWY')
  79. )
  80. begin
  81. declare @CurrentUser sysname
  82. select @CurrentUser = user_name()
  83. execute sp_dropextendedproperty 'MS_Description',
  84. 'user', @CurrentUser, 'table', 'ADRES', 'column', 'KOD_POCZTOWY'
  85.  
  86. end
  87.  
  88.  
  89. select @CurrentUser = user_name()
  90. execute sp_addextendedproperty 'MS_Description',
  91. 'kod pocztowy osoby',
  92. 'user', @CurrentUser, 'table', 'ADRES', 'column', 'KOD_POCZTOWY'
  93. go
  94.  
  95. if exists(select 1 from sys.extended_properties p where
  96. p.major_id = object_id('ADRES')
  97. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ULICA')
  98. )
  99. begin
  100. declare @CurrentUser sysname
  101. select @CurrentUser = user_name()
  102. execute sp_dropextendedproperty 'MS_Description',
  103. 'user', @CurrentUser, 'table', 'ADRES', 'column', 'ULICA'
  104.  
  105. end
  106.  
  107.  
  108. select @CurrentUser = user_name()
  109. execute sp_addextendedproperty 'MS_Description',
  110. 'ulica na jakiej mieszka dana osoba',
  111. 'user', @CurrentUser, 'table', 'ADRES', 'column', 'ULICA'
  112. go
  113.  
  114. if exists(select 1 from sys.extended_properties p where
  115. p.major_id = object_id('ADRES')
  116. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'NR')
  117. )
  118. begin
  119. declare @CurrentUser sysname
  120. select @CurrentUser = user_name()
  121. execute sp_dropextendedproperty 'MS_Description',
  122. 'user', @CurrentUser, 'table', 'ADRES', 'column', 'NR'
  123.  
  124. end
  125.  
  126.  
  127. select @CurrentUser = user_name()
  128. execute sp_addextendedproperty 'MS_Description',
  129. 'numer mieszkania na jakim mieszka dana osoba',
  130. 'user', @CurrentUser, 'table', 'ADRES', 'column', 'NR'
  131. go
  132.  
  133. /*==============================================================*/
  134. /* Table: AKTOR */
  135. /*==============================================================*/
  136. create table AKTOR (
  137. ID_AKTORA int not null,
  138. IMIE varchar(30) not null,
  139. NAZWISKO varchar(30) not null,
  140. constraint PK_AKTOR primary key nonclustered (ID_AKTORA)
  141. )
  142. go
  143.  
  144. if exists (select 1 from sys.extended_properties
  145. where major_id = object_id('AKTOR') and minor_id = 0)
  146. begin
  147. declare @CurrentUser sysname
  148. select @CurrentUser = user_name()
  149. execute sp_dropextendedproperty 'MS_Description',
  150. 'user', @CurrentUser, 'table', 'AKTOR'
  151.  
  152. end
  153.  
  154.  
  155. select @CurrentUser = user_name()
  156. execute sp_addextendedproperty 'MS_Description',
  157. 'Encja opisująca aktora',
  158. 'user', @CurrentUser, 'table', 'AKTOR'
  159. go
  160.  
  161. if exists(select 1 from sys.extended_properties p where
  162. p.major_id = object_id('AKTOR')
  163. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_AKTORA')
  164. )
  165. begin
  166. declare @CurrentUser sysname
  167. select @CurrentUser = user_name()
  168. execute sp_dropextendedproperty 'MS_Description',
  169. 'user', @CurrentUser, 'table', 'AKTOR', 'column', 'ID_AKTORA'
  170.  
  171. end
  172.  
  173.  
  174. select @CurrentUser = user_name()
  175. execute sp_addextendedproperty 'MS_Description',
  176. 'id aktora
  177. ',
  178. 'user', @CurrentUser, 'table', 'AKTOR', 'column', 'ID_AKTORA'
  179. go
  180.  
  181. if exists(select 1 from sys.extended_properties p where
  182. p.major_id = object_id('AKTOR')
  183. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'IMIE')
  184. )
  185. begin
  186. declare @CurrentUser sysname
  187. select @CurrentUser = user_name()
  188. execute sp_dropextendedproperty 'MS_Description',
  189. 'user', @CurrentUser, 'table', 'AKTOR', 'column', 'IMIE'
  190.  
  191. end
  192.  
  193.  
  194. select @CurrentUser = user_name()
  195. execute sp_addextendedproperty 'MS_Description',
  196. 'imie aktora',
  197. 'user', @CurrentUser, 'table', 'AKTOR', 'column', 'IMIE'
  198. go
  199.  
  200. if exists(select 1 from sys.extended_properties p where
  201. p.major_id = object_id('AKTOR')
  202. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'NAZWISKO')
  203. )
  204. begin
  205. declare @CurrentUser sysname
  206. select @CurrentUser = user_name()
  207. execute sp_dropextendedproperty 'MS_Description',
  208. 'user', @CurrentUser, 'table', 'AKTOR', 'column', 'NAZWISKO'
  209.  
  210. end
  211.  
  212.  
  213. select @CurrentUser = user_name()
  214. execute sp_addextendedproperty 'MS_Description',
  215. 'nazwisko aktora',
  216. 'user', @CurrentUser, 'table', 'AKTOR', 'column', 'NAZWISKO'
  217. go
  218.  
  219. /*==============================================================*/
  220. /* Table: AKTOR_FILM */
  221. /*==============================================================*/
  222. create table AKTOR_FILM (
  223. ID_FILMU int not null,
  224. ID_AKTORA int not null
  225. )
  226. go
  227.  
  228. if exists (select 1 from sys.extended_properties
  229. where major_id = object_id('AKTOR_FILM') and minor_id = 0)
  230. begin
  231. declare @CurrentUser sysname
  232. select @CurrentUser = user_name()
  233. execute sp_dropextendedproperty 'MS_Description',
  234. 'user', @CurrentUser, 'table', 'AKTOR_FILM'
  235.  
  236. end
  237.  
  238.  
  239. select @CurrentUser = user_name()
  240. execute sp_addextendedproperty 'MS_Description',
  241. 'INTERSEKCJA AKTOR-FILM',
  242. 'user', @CurrentUser, 'table', 'AKTOR_FILM'
  243. go
  244.  
  245. if exists(select 1 from sys.extended_properties p where
  246. p.major_id = object_id('AKTOR_FILM')
  247. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_FILMU')
  248. )
  249. begin
  250. declare @CurrentUser sysname
  251. select @CurrentUser = user_name()
  252. execute sp_dropextendedproperty 'MS_Description',
  253. 'user', @CurrentUser, 'table', 'AKTOR_FILM', 'column', 'ID_FILMU'
  254.  
  255. end
  256.  
  257.  
  258. select @CurrentUser = user_name()
  259. execute sp_addextendedproperty 'MS_Description',
  260. 'ID wypozyczanego filmu ',
  261. 'user', @CurrentUser, 'table', 'AKTOR_FILM', 'column', 'ID_FILMU'
  262. go
  263.  
  264. if exists(select 1 from sys.extended_properties p where
  265. p.major_id = object_id('AKTOR_FILM')
  266. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_AKTORA')
  267. )
  268. begin
  269. declare @CurrentUser sysname
  270. select @CurrentUser = user_name()
  271. execute sp_dropextendedproperty 'MS_Description',
  272. 'user', @CurrentUser, 'table', 'AKTOR_FILM', 'column', 'ID_AKTORA'
  273.  
  274. end
  275.  
  276.  
  277. select @CurrentUser = user_name()
  278. execute sp_addextendedproperty 'MS_Description',
  279. 'id aktora
  280. ',
  281. 'user', @CurrentUser, 'table', 'AKTOR_FILM', 'column', 'ID_AKTORA'
  282. go
  283.  
  284. /*==============================================================*/
  285. /* Index: FK_AKTOR_AKTORFILM_FK */
  286. /*==============================================================*/
  287. create index FK_AKTOR_AKTORFILM_FK on AKTOR_FILM (
  288. ID_AKTORA ASC
  289. )
  290. go
  291.  
  292. /*==============================================================*/
  293. /* Index: FK_FILM_AKTORFILM_FK */
  294. /*==============================================================*/
  295. create index FK_FILM_AKTORFILM_FK on AKTOR_FILM (
  296. ID_FILMU ASC
  297. )
  298. go
  299.  
  300. /*==============================================================*/
  301. /* Table: AUTOR */
  302. /*==============================================================*/
  303. create table AUTOR (
  304. ID_AUTORA int not null,
  305. IMIE varchar(30) not null,
  306. NAZWISKO varchar(30) not null,
  307. constraint PK_AUTOR primary key nonclustered (ID_AUTORA)
  308. )
  309. go
  310.  
  311. if exists (select 1 from sys.extended_properties
  312. where major_id = object_id('AUTOR') and minor_id = 0)
  313. begin
  314. declare @CurrentUser sysname
  315. select @CurrentUser = user_name()
  316. execute sp_dropextendedproperty 'MS_Description',
  317. 'user', @CurrentUser, 'table', 'AUTOR'
  318.  
  319. end
  320.  
  321.  
  322. select @CurrentUser = user_name()
  323. execute sp_addextendedproperty 'MS_Description',
  324. 'encja opisująca Autora',
  325. 'user', @CurrentUser, 'table', 'AUTOR'
  326. go
  327.  
  328. if exists(select 1 from sys.extended_properties p where
  329. p.major_id = object_id('AUTOR')
  330. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_AUTORA')
  331. )
  332. begin
  333. declare @CurrentUser sysname
  334. select @CurrentUser = user_name()
  335. execute sp_dropextendedproperty 'MS_Description',
  336. 'user', @CurrentUser, 'table', 'AUTOR', 'column', 'ID_AUTORA'
  337.  
  338. end
  339.  
  340.  
  341. select @CurrentUser = user_name()
  342. execute sp_addextendedproperty 'MS_Description',
  343. 'ID_AUTORA',
  344. 'user', @CurrentUser, 'table', 'AUTOR', 'column', 'ID_AUTORA'
  345. go
  346.  
  347. if exists(select 1 from sys.extended_properties p where
  348. p.major_id = object_id('AUTOR')
  349. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'IMIE')
  350. )
  351. begin
  352. declare @CurrentUser sysname
  353. select @CurrentUser = user_name()
  354. execute sp_dropextendedproperty 'MS_Description',
  355. 'user', @CurrentUser, 'table', 'AUTOR', 'column', 'IMIE'
  356.  
  357. end
  358.  
  359.  
  360. select @CurrentUser = user_name()
  361. execute sp_addextendedproperty 'MS_Description',
  362. 'Imie autora',
  363. 'user', @CurrentUser, 'table', 'AUTOR', 'column', 'IMIE'
  364. go
  365.  
  366. if exists(select 1 from sys.extended_properties p where
  367. p.major_id = object_id('AUTOR')
  368. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'NAZWISKO')
  369. )
  370. begin
  371. declare @CurrentUser sysname
  372. select @CurrentUser = user_name()
  373. execute sp_dropextendedproperty 'MS_Description',
  374. 'user', @CurrentUser, 'table', 'AUTOR', 'column', 'NAZWISKO'
  375.  
  376. end
  377.  
  378.  
  379. select @CurrentUser = user_name()
  380. execute sp_addextendedproperty 'MS_Description',
  381. 'nazwisko autora',
  382. 'user', @CurrentUser, 'table', 'AUTOR', 'column', 'NAZWISKO'
  383. go
  384.  
  385. /*==============================================================*/
  386. /* Table: AUTOR_FILM */
  387. /*==============================================================*/
  388. create table AUTOR_FILM (
  389. ID_FILMU int not null,
  390. ID_AUTORA int not null
  391. )
  392. go
  393.  
  394. if exists (select 1 from sys.extended_properties
  395. where major_id = object_id('AUTOR_FILM') and minor_id = 0)
  396. begin
  397. declare @CurrentUser sysname
  398. select @CurrentUser = user_name()
  399. execute sp_dropextendedproperty 'MS_Description',
  400. 'user', @CurrentUser, 'table', 'AUTOR_FILM'
  401.  
  402. end
  403.  
  404.  
  405. select @CurrentUser = user_name()
  406. execute sp_addextendedproperty 'MS_Description',
  407. 'intersekcja FILM-AUTOR',
  408. 'user', @CurrentUser, 'table', 'AUTOR_FILM'
  409. go
  410.  
  411. if exists(select 1 from sys.extended_properties p where
  412. p.major_id = object_id('AUTOR_FILM')
  413. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_FILMU')
  414. )
  415. begin
  416. declare @CurrentUser sysname
  417. select @CurrentUser = user_name()
  418. execute sp_dropextendedproperty 'MS_Description',
  419. 'user', @CurrentUser, 'table', 'AUTOR_FILM', 'column', 'ID_FILMU'
  420.  
  421. end
  422.  
  423.  
  424. select @CurrentUser = user_name()
  425. execute sp_addextendedproperty 'MS_Description',
  426. 'ID wypozyczanego filmu ',
  427. 'user', @CurrentUser, 'table', 'AUTOR_FILM', 'column', 'ID_FILMU'
  428. go
  429.  
  430. if exists(select 1 from sys.extended_properties p where
  431. p.major_id = object_id('AUTOR_FILM')
  432. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_AUTORA')
  433. )
  434. begin
  435. declare @CurrentUser sysname
  436. select @CurrentUser = user_name()
  437. execute sp_dropextendedproperty 'MS_Description',
  438. 'user', @CurrentUser, 'table', 'AUTOR_FILM', 'column', 'ID_AUTORA'
  439.  
  440. end
  441.  
  442.  
  443. select @CurrentUser = user_name()
  444. execute sp_addextendedproperty 'MS_Description',
  445. 'ID_AUTORA',
  446. 'user', @CurrentUser, 'table', 'AUTOR_FILM', 'column', 'ID_AUTORA'
  447. go
  448.  
  449. /*==============================================================*/
  450. /* Index: FK_AUTOR_AUTORFILM_FK */
  451. /*==============================================================*/
  452. create index FK_AUTOR_AUTORFILM_FK on AUTOR_FILM (
  453. ID_AUTORA ASC
  454. )
  455. go
  456.  
  457. /*==============================================================*/
  458. /* Index: FK_FILM_AUTORFILM_FK */
  459. /*==============================================================*/
  460. create index FK_FILM_AUTORFILM_FK on AUTOR_FILM (
  461. ID_FILMU ASC
  462. )
  463. go
  464.  
  465. /*==============================================================*/
  466. /* Table: FILM */
  467. /*==============================================================*/
  468. create table FILM (
  469. ID_FILMU int not null,
  470. ID_JEZYKA int null,
  471. TYTUL varchar(100) not null,
  472. OPIS varchar(100) not null,
  473. ROK int not null,
  474. CZAS_WYPOZYCZENIA int not null,
  475. CENA_WYNAJMU float not null,
  476. OCENA float null,
  477. constraint PK_FILM primary key nonclustered (ID_FILMU)
  478. )
  479. go
  480.  
  481. if exists (select 1 from sys.extended_properties
  482. where major_id = object_id('FILM') and minor_id = 0)
  483. begin
  484. declare @CurrentUser sysname
  485. select @CurrentUser = user_name()
  486. execute sp_dropextendedproperty 'MS_Description',
  487. 'user', @CurrentUser, 'table', 'FILM'
  488.  
  489. end
  490.  
  491.  
  492. select @CurrentUser = user_name()
  493. execute sp_addextendedproperty 'MS_Description',
  494. 'Film który ma zostac wypozyczony',
  495. 'user', @CurrentUser, 'table', 'FILM'
  496. go
  497.  
  498. if exists(select 1 from sys.extended_properties p where
  499. p.major_id = object_id('FILM')
  500. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_FILMU')
  501. )
  502. begin
  503. declare @CurrentUser sysname
  504. select @CurrentUser = user_name()
  505. execute sp_dropextendedproperty 'MS_Description',
  506. 'user', @CurrentUser, 'table', 'FILM', 'column', 'ID_FILMU'
  507.  
  508. end
  509.  
  510.  
  511. select @CurrentUser = user_name()
  512. execute sp_addextendedproperty 'MS_Description',
  513. 'ID wypozyczanego filmu ',
  514. 'user', @CurrentUser, 'table', 'FILM', 'column', 'ID_FILMU'
  515. go
  516.  
  517. if exists(select 1 from sys.extended_properties p where
  518. p.major_id = object_id('FILM')
  519. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_JEZYKA')
  520. )
  521. begin
  522. declare @CurrentUser sysname
  523. select @CurrentUser = user_name()
  524. execute sp_dropextendedproperty 'MS_Description',
  525. 'user', @CurrentUser, 'table', 'FILM', 'column', 'ID_JEZYKA'
  526.  
  527. end
  528.  
  529.  
  530. select @CurrentUser = user_name()
  531. execute sp_addextendedproperty 'MS_Description',
  532. 'id jezyka',
  533. 'user', @CurrentUser, 'table', 'FILM', 'column', 'ID_JEZYKA'
  534. go
  535.  
  536. if exists(select 1 from sys.extended_properties p where
  537. p.major_id = object_id('FILM')
  538. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'TYTUL')
  539. )
  540. begin
  541. declare @CurrentUser sysname
  542. select @CurrentUser = user_name()
  543. execute sp_dropextendedproperty 'MS_Description',
  544. 'user', @CurrentUser, 'table', 'FILM', 'column', 'TYTUL'
  545.  
  546. end
  547.  
  548.  
  549. select @CurrentUser = user_name()
  550. execute sp_addextendedproperty 'MS_Description',
  551. 'tytul filmu',
  552. 'user', @CurrentUser, 'table', 'FILM', 'column', 'TYTUL'
  553. go
  554.  
  555. if exists(select 1 from sys.extended_properties p where
  556. p.major_id = object_id('FILM')
  557. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'OPIS')
  558. )
  559. begin
  560. declare @CurrentUser sysname
  561. select @CurrentUser = user_name()
  562. execute sp_dropextendedproperty 'MS_Description',
  563. 'user', @CurrentUser, 'table', 'FILM', 'column', 'OPIS'
  564.  
  565. end
  566.  
  567.  
  568. select @CurrentUser = user_name()
  569. execute sp_addextendedproperty 'MS_Description',
  570. 'opis filmu',
  571. 'user', @CurrentUser, 'table', 'FILM', 'column', 'OPIS'
  572. go
  573.  
  574. if exists(select 1 from sys.extended_properties p where
  575. p.major_id = object_id('FILM')
  576. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ROK')
  577. )
  578. begin
  579. declare @CurrentUser sysname
  580. select @CurrentUser = user_name()
  581. execute sp_dropextendedproperty 'MS_Description',
  582. 'user', @CurrentUser, 'table', 'FILM', 'column', 'ROK'
  583.  
  584. end
  585.  
  586.  
  587. select @CurrentUser = user_name()
  588. execute sp_addextendedproperty 'MS_Description',
  589. 'rok wydania filmu',
  590. 'user', @CurrentUser, 'table', 'FILM', 'column', 'ROK'
  591. go
  592.  
  593. if exists(select 1 from sys.extended_properties p where
  594. p.major_id = object_id('FILM')
  595. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'CZAS_WYPOZYCZENIA')
  596. )
  597. begin
  598. declare @CurrentUser sysname
  599. select @CurrentUser = user_name()
  600. execute sp_dropextendedproperty 'MS_Description',
  601. 'user', @CurrentUser, 'table', 'FILM', 'column', 'CZAS_WYPOZYCZENIA'
  602.  
  603. end
  604.  
  605.  
  606. select @CurrentUser = user_name()
  607. execute sp_addextendedproperty 'MS_Description',
  608. 'na jaki okres czasu wypozyczany jest film
  609. ',
  610. 'user', @CurrentUser, 'table', 'FILM', 'column', 'CZAS_WYPOZYCZENIA'
  611. go
  612.  
  613. if exists(select 1 from sys.extended_properties p where
  614. p.major_id = object_id('FILM')
  615. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'CENA_WYNAJMU')
  616. )
  617. begin
  618. declare @CurrentUser sysname
  619. select @CurrentUser = user_name()
  620. execute sp_dropextendedproperty 'MS_Description',
  621. 'user', @CurrentUser, 'table', 'FILM', 'column', 'CENA_WYNAJMU'
  622.  
  623. end
  624.  
  625.  
  626. select @CurrentUser = user_name()
  627. execute sp_addextendedproperty 'MS_Description',
  628. 'ena za dzien wypozyczenia',
  629. 'user', @CurrentUser, 'table', 'FILM', 'column', 'CENA_WYNAJMU'
  630. go
  631.  
  632. if exists(select 1 from sys.extended_properties p where
  633. p.major_id = object_id('FILM')
  634. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'OCENA')
  635. )
  636. begin
  637. declare @CurrentUser sysname
  638. select @CurrentUser = user_name()
  639. execute sp_dropextendedproperty 'MS_Description',
  640. 'user', @CurrentUser, 'table', 'FILM', 'column', 'OCENA'
  641.  
  642. end
  643.  
  644.  
  645. select @CurrentUser = user_name()
  646. execute sp_addextendedproperty 'MS_Description',
  647. 'ocena filmu przez klientow ktorzy obejrzeli film',
  648. 'user', @CurrentUser, 'table', 'FILM', 'column', 'OCENA'
  649. go
  650.  
  651. /*==============================================================*/
  652. /* Index: FK_JEZYK_FILM_FK */
  653. /*==============================================================*/
  654. create index FK_JEZYK_FILM_FK on FILM (
  655. ID_JEZYKA ASC
  656. )
  657. go
  658.  
  659. /*==============================================================*/
  660. /* Table: GATUNEK */
  661. /*==============================================================*/
  662. create table GATUNEK (
  663. ID_GATUNKU int not null,
  664. GATUNEK varchar(30) not null,
  665. constraint PK_GATUNEK primary key nonclustered (ID_GATUNKU)
  666. )
  667. go
  668.  
  669. if exists (select 1 from sys.extended_properties
  670. where major_id = object_id('GATUNEK') and minor_id = 0)
  671. begin
  672. declare @CurrentUser sysname
  673. select @CurrentUser = user_name()
  674. execute sp_dropextendedproperty 'MS_Description',
  675. 'user', @CurrentUser, 'table', 'GATUNEK'
  676.  
  677. end
  678.  
  679.  
  680. select @CurrentUser = user_name()
  681. execute sp_addextendedproperty 'MS_Description',
  682. 'encja opisująca gatunek',
  683. 'user', @CurrentUser, 'table', 'GATUNEK'
  684. go
  685.  
  686. if exists(select 1 from sys.extended_properties p where
  687. p.major_id = object_id('GATUNEK')
  688. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'GATUNEK')
  689. )
  690. begin
  691. declare @CurrentUser sysname
  692. select @CurrentUser = user_name()
  693. execute sp_dropextendedproperty 'MS_Description',
  694. 'user', @CurrentUser, 'table', 'GATUNEK', 'column', 'GATUNEK'
  695.  
  696. end
  697.  
  698.  
  699. select @CurrentUser = user_name()
  700. execute sp_addextendedproperty 'MS_Description',
  701. 'Gatunek filmu',
  702. 'user', @CurrentUser, 'table', 'GATUNEK', 'column', 'GATUNEK'
  703. go
  704.  
  705. /*==============================================================*/
  706. /* Table: GATUNEK_FILM */
  707. /*==============================================================*/
  708. create table GATUNEK_FILM (
  709. ID_GATUNKU int not null,
  710. ID_FILMU int not null
  711. )
  712. go
  713.  
  714. if exists (select 1 from sys.extended_properties
  715. where major_id = object_id('GATUNEK_FILM') and minor_id = 0)
  716. begin
  717. declare @CurrentUser sysname
  718. select @CurrentUser = user_name()
  719. execute sp_dropextendedproperty 'MS_Description',
  720. 'user', @CurrentUser, 'table', 'GATUNEK_FILM'
  721.  
  722. end
  723.  
  724.  
  725. select @CurrentUser = user_name()
  726. execute sp_addextendedproperty 'MS_Description',
  727. 'intersekcja FILM-Gatunek',
  728. 'user', @CurrentUser, 'table', 'GATUNEK_FILM'
  729. go
  730.  
  731. if exists(select 1 from sys.extended_properties p where
  732. p.major_id = object_id('GATUNEK_FILM')
  733. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_FILMU')
  734. )
  735. begin
  736. declare @CurrentUser sysname
  737. select @CurrentUser = user_name()
  738. execute sp_dropextendedproperty 'MS_Description',
  739. 'user', @CurrentUser, 'table', 'GATUNEK_FILM', 'column', 'ID_FILMU'
  740.  
  741. end
  742.  
  743.  
  744. select @CurrentUser = user_name()
  745. execute sp_addextendedproperty 'MS_Description',
  746. 'ID wypozyczanego filmu ',
  747. 'user', @CurrentUser, 'table', 'GATUNEK_FILM', 'column', 'ID_FILMU'
  748. go
  749.  
  750. /*==============================================================*/
  751. /* Index: FK_FILM_GATUNEKFILM_FK */
  752. /*==============================================================*/
  753. create index FK_FILM_GATUNEKFILM_FK on GATUNEK_FILM (
  754. ID_FILMU ASC
  755. )
  756. go
  757.  
  758. /*==============================================================*/
  759. /* Index: FK_GATUNEK_GATUNEKFILM_FK */
  760. /*==============================================================*/
  761. create index FK_GATUNEK_GATUNEKFILM_FK on GATUNEK_FILM (
  762. ID_GATUNKU ASC
  763. )
  764. go
  765.  
  766. /*==============================================================*/
  767. /* Table: JEZYK */
  768. /*==============================================================*/
  769. create table JEZYK (
  770. ID_JEZYKA int not null,
  771. NAZWA varchar(50) not null,
  772. constraint PK_JEZYK primary key nonclustered (ID_JEZYKA)
  773. )
  774. go
  775.  
  776. if exists (select 1 from sys.extended_properties
  777. where major_id = object_id('JEZYK') and minor_id = 0)
  778. begin
  779. declare @CurrentUser sysname
  780. select @CurrentUser = user_name()
  781. execute sp_dropextendedproperty 'MS_Description',
  782. 'user', @CurrentUser, 'table', 'JEZYK'
  783.  
  784. end
  785.  
  786.  
  787. select @CurrentUser = user_name()
  788. execute sp_addextendedproperty 'MS_Description',
  789. 'W jakim jezyku jest nagrany film',
  790. 'user', @CurrentUser, 'table', 'JEZYK'
  791. go
  792.  
  793. if exists(select 1 from sys.extended_properties p where
  794. p.major_id = object_id('JEZYK')
  795. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_JEZYKA')
  796. )
  797. begin
  798. declare @CurrentUser sysname
  799. select @CurrentUser = user_name()
  800. execute sp_dropextendedproperty 'MS_Description',
  801. 'user', @CurrentUser, 'table', 'JEZYK', 'column', 'ID_JEZYKA'
  802.  
  803. end
  804.  
  805.  
  806. select @CurrentUser = user_name()
  807. execute sp_addextendedproperty 'MS_Description',
  808. 'id jezyka',
  809. 'user', @CurrentUser, 'table', 'JEZYK', 'column', 'ID_JEZYKA'
  810. go
  811.  
  812. if exists(select 1 from sys.extended_properties p where
  813. p.major_id = object_id('JEZYK')
  814. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'NAZWA')
  815. )
  816. begin
  817. declare @CurrentUser sysname
  818. select @CurrentUser = user_name()
  819. execute sp_dropextendedproperty 'MS_Description',
  820. 'user', @CurrentUser, 'table', 'JEZYK', 'column', 'NAZWA'
  821.  
  822. end
  823.  
  824.  
  825. select @CurrentUser = user_name()
  826. execute sp_addextendedproperty 'MS_Description',
  827. 'NAZWA JEZYKA',
  828. 'user', @CurrentUser, 'table', 'JEZYK', 'column', 'NAZWA'
  829. go
  830.  
  831. /*==============================================================*/
  832. /* Table: KLIENT */
  833. /*==============================================================*/
  834. create table KLIENT (
  835. ID_KLIENTA int not null,
  836. ID_ADRES int not null,
  837. IMIE varchar(30) not null,
  838. NAZWISKO varchar(30) not null,
  839. EMAIL varchar(50) null,
  840. NIP char(13) not null,
  841. PESEL char(11) not null,
  842. TELEFON varchar(12) null,
  843. constraint PK_KLIENT primary key (ID_KLIENTA)
  844. )
  845. go
  846.  
  847. if exists (select 1 from sys.extended_properties
  848. where major_id = object_id('KLIENT') and minor_id = 0)
  849. begin
  850. declare @CurrentUser sysname
  851. select @CurrentUser = user_name()
  852. execute sp_dropextendedproperty 'MS_Description',
  853. 'user', @CurrentUser, 'table', 'KLIENT'
  854.  
  855. end
  856.  
  857.  
  858. select @CurrentUser = user_name()
  859. execute sp_addextendedproperty 'MS_Description',
  860. 'klient który chce wypozyczyc film',
  861. 'user', @CurrentUser, 'table', 'KLIENT'
  862. go
  863.  
  864. if exists(select 1 from sys.extended_properties p where
  865. p.major_id = object_id('KLIENT')
  866. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_KLIENTA')
  867. )
  868. begin
  869. declare @CurrentUser sysname
  870. select @CurrentUser = user_name()
  871. execute sp_dropextendedproperty 'MS_Description',
  872. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'ID_KLIENTA'
  873.  
  874. end
  875.  
  876.  
  877. select @CurrentUser = user_name()
  878. execute sp_addextendedproperty 'MS_Description',
  879. 'ID_KLIENTA',
  880. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'ID_KLIENTA'
  881. go
  882.  
  883. if exists(select 1 from sys.extended_properties p where
  884. p.major_id = object_id('KLIENT')
  885. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_ADRES')
  886. )
  887. begin
  888. declare @CurrentUser sysname
  889. select @CurrentUser = user_name()
  890. execute sp_dropextendedproperty 'MS_Description',
  891. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'ID_ADRES'
  892.  
  893. end
  894.  
  895.  
  896. select @CurrentUser = user_name()
  897. execute sp_addextendedproperty 'MS_Description',
  898. 'ID_ADRES',
  899. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'ID_ADRES'
  900. go
  901.  
  902. if exists(select 1 from sys.extended_properties p where
  903. p.major_id = object_id('KLIENT')
  904. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'IMIE')
  905. )
  906. begin
  907. declare @CurrentUser sysname
  908. select @CurrentUser = user_name()
  909. execute sp_dropextendedproperty 'MS_Description',
  910. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'IMIE'
  911.  
  912. end
  913.  
  914.  
  915. select @CurrentUser = user_name()
  916. execute sp_addextendedproperty 'MS_Description',
  917. 'IMIE pracownika lub klienta',
  918. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'IMIE'
  919. go
  920.  
  921. if exists(select 1 from sys.extended_properties p where
  922. p.major_id = object_id('KLIENT')
  923. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'NAZWISKO')
  924. )
  925. begin
  926. declare @CurrentUser sysname
  927. select @CurrentUser = user_name()
  928. execute sp_dropextendedproperty 'MS_Description',
  929. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'NAZWISKO'
  930.  
  931. end
  932.  
  933.  
  934. select @CurrentUser = user_name()
  935. execute sp_addextendedproperty 'MS_Description',
  936. 'nazwisko pracownika lub klienta',
  937. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'NAZWISKO'
  938. go
  939.  
  940. if exists(select 1 from sys.extended_properties p where
  941. p.major_id = object_id('KLIENT')
  942. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'EMAIL')
  943. )
  944. begin
  945. declare @CurrentUser sysname
  946. select @CurrentUser = user_name()
  947. execute sp_dropextendedproperty 'MS_Description',
  948. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'EMAIL'
  949.  
  950. end
  951.  
  952.  
  953. select @CurrentUser = user_name()
  954. execute sp_addextendedproperty 'MS_Description',
  955. 'email pracownika lub klienta',
  956. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'EMAIL'
  957. go
  958.  
  959. if exists(select 1 from sys.extended_properties p where
  960. p.major_id = object_id('KLIENT')
  961. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'NIP')
  962. )
  963. begin
  964. declare @CurrentUser sysname
  965. select @CurrentUser = user_name()
  966. execute sp_dropextendedproperty 'MS_Description',
  967. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'NIP'
  968.  
  969. end
  970.  
  971.  
  972. select @CurrentUser = user_name()
  973. execute sp_addextendedproperty 'MS_Description',
  974. 'NIP pracownika lub klienta',
  975. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'NIP'
  976. go
  977.  
  978. if exists(select 1 from sys.extended_properties p where
  979. p.major_id = object_id('KLIENT')
  980. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'PESEL')
  981. )
  982. begin
  983. declare @CurrentUser sysname
  984. select @CurrentUser = user_name()
  985. execute sp_dropextendedproperty 'MS_Description',
  986. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'PESEL'
  987.  
  988. end
  989.  
  990.  
  991. select @CurrentUser = user_name()
  992. execute sp_addextendedproperty 'MS_Description',
  993. 'pesel pracownika lub klienta
  994. ',
  995. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'PESEL'
  996. go
  997.  
  998. if exists(select 1 from sys.extended_properties p where
  999. p.major_id = object_id('KLIENT')
  1000. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'TELEFON')
  1001. )
  1002. begin
  1003. declare @CurrentUser sysname
  1004. select @CurrentUser = user_name()
  1005. execute sp_dropextendedproperty 'MS_Description',
  1006. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'TELEFON'
  1007.  
  1008. end
  1009.  
  1010.  
  1011. select @CurrentUser = user_name()
  1012. execute sp_addextendedproperty 'MS_Description',
  1013. 'telefon pracownika lub klienta',
  1014. 'user', @CurrentUser, 'table', 'KLIENT', 'column', 'TELEFON'
  1015. go
  1016.  
  1017. /*==============================================================*/
  1018. /* Index: FK_OSOBA_ADRES2_FK */
  1019. /*==============================================================*/
  1020. create index FK_OSOBA_ADRES2_FK on KLIENT (
  1021. ID_ADRES ASC
  1022. )
  1023. go
  1024.  
  1025. /*==============================================================*/
  1026. /* Table: PRACOWNIK */
  1027. /*==============================================================*/
  1028. create table PRACOWNIK (
  1029. ID_KLIENTA int not null,
  1030. ID_ADRES int not null,
  1031. IMIE varchar(30) not null,
  1032. NAZWISKO varchar(30) not null,
  1033. EMAIL varchar(50) null,
  1034. NIP char(13) not null,
  1035. PESEL char(11) not null,
  1036. TELEFON varchar(12) null,
  1037. constraint PK_PRACOWNIK primary key (ID_KLIENTA)
  1038. )
  1039. go
  1040.  
  1041. if exists (select 1 from sys.extended_properties
  1042. where major_id = object_id('PRACOWNIK') and minor_id = 0)
  1043. begin
  1044. declare @CurrentUser sysname
  1045. select @CurrentUser = user_name()
  1046. execute sp_dropextendedproperty 'MS_Description',
  1047. 'user', @CurrentUser, 'table', 'PRACOWNIK'
  1048.  
  1049. end
  1050.  
  1051.  
  1052. select @CurrentUser = user_name()
  1053. execute sp_addextendedproperty 'MS_Description',
  1054. 'pracownik wypozyczalni',
  1055. 'user', @CurrentUser, 'table', 'PRACOWNIK'
  1056. go
  1057.  
  1058. if exists(select 1 from sys.extended_properties p where
  1059. p.major_id = object_id('PRACOWNIK')
  1060. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_KLIENTA')
  1061. )
  1062. begin
  1063. declare @CurrentUser sysname
  1064. select @CurrentUser = user_name()
  1065. execute sp_dropextendedproperty 'MS_Description',
  1066. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'ID_KLIENTA'
  1067.  
  1068. end
  1069.  
  1070.  
  1071. select @CurrentUser = user_name()
  1072. execute sp_addextendedproperty 'MS_Description',
  1073. 'ID_KLIENTA',
  1074. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'ID_KLIENTA'
  1075. go
  1076.  
  1077. if exists(select 1 from sys.extended_properties p where
  1078. p.major_id = object_id('PRACOWNIK')
  1079. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_ADRES')
  1080. )
  1081. begin
  1082. declare @CurrentUser sysname
  1083. select @CurrentUser = user_name()
  1084. execute sp_dropextendedproperty 'MS_Description',
  1085. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'ID_ADRES'
  1086.  
  1087. end
  1088.  
  1089.  
  1090. select @CurrentUser = user_name()
  1091. execute sp_addextendedproperty 'MS_Description',
  1092. 'ID_ADRES',
  1093. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'ID_ADRES'
  1094. go
  1095.  
  1096. if exists(select 1 from sys.extended_properties p where
  1097. p.major_id = object_id('PRACOWNIK')
  1098. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'IMIE')
  1099. )
  1100. begin
  1101. declare @CurrentUser sysname
  1102. select @CurrentUser = user_name()
  1103. execute sp_dropextendedproperty 'MS_Description',
  1104. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'IMIE'
  1105.  
  1106. end
  1107.  
  1108.  
  1109. select @CurrentUser = user_name()
  1110. execute sp_addextendedproperty 'MS_Description',
  1111. 'IMIE pracownika lub klienta',
  1112. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'IMIE'
  1113. go
  1114.  
  1115. if exists(select 1 from sys.extended_properties p where
  1116. p.major_id = object_id('PRACOWNIK')
  1117. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'NAZWISKO')
  1118. )
  1119. begin
  1120. declare @CurrentUser sysname
  1121. select @CurrentUser = user_name()
  1122. execute sp_dropextendedproperty 'MS_Description',
  1123. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'NAZWISKO'
  1124.  
  1125. end
  1126.  
  1127.  
  1128. select @CurrentUser = user_name()
  1129. execute sp_addextendedproperty 'MS_Description',
  1130. 'nazwisko pracownika lub klienta',
  1131. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'NAZWISKO'
  1132. go
  1133.  
  1134. if exists(select 1 from sys.extended_properties p where
  1135. p.major_id = object_id('PRACOWNIK')
  1136. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'EMAIL')
  1137. )
  1138. begin
  1139. declare @CurrentUser sysname
  1140. select @CurrentUser = user_name()
  1141. execute sp_dropextendedproperty 'MS_Description',
  1142. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'EMAIL'
  1143.  
  1144. end
  1145.  
  1146.  
  1147. select @CurrentUser = user_name()
  1148. execute sp_addextendedproperty 'MS_Description',
  1149. 'email pracownika lub klienta',
  1150. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'EMAIL'
  1151. go
  1152.  
  1153. if exists(select 1 from sys.extended_properties p where
  1154. p.major_id = object_id('PRACOWNIK')
  1155. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'NIP')
  1156. )
  1157. begin
  1158. declare @CurrentUser sysname
  1159. select @CurrentUser = user_name()
  1160. execute sp_dropextendedproperty 'MS_Description',
  1161. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'NIP'
  1162.  
  1163. end
  1164.  
  1165.  
  1166. select @CurrentUser = user_name()
  1167. execute sp_addextendedproperty 'MS_Description',
  1168. 'NIP pracownika lub klienta',
  1169. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'NIP'
  1170. go
  1171.  
  1172. if exists(select 1 from sys.extended_properties p where
  1173. p.major_id = object_id('PRACOWNIK')
  1174. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'PESEL')
  1175. )
  1176. begin
  1177. declare @CurrentUser sysname
  1178. select @CurrentUser = user_name()
  1179. execute sp_dropextendedproperty 'MS_Description',
  1180. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'PESEL'
  1181.  
  1182. end
  1183.  
  1184.  
  1185. select @CurrentUser = user_name()
  1186. execute sp_addextendedproperty 'MS_Description',
  1187. 'pesel pracownika lub klienta
  1188. ',
  1189. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'PESEL'
  1190. go
  1191.  
  1192. if exists(select 1 from sys.extended_properties p where
  1193. p.major_id = object_id('PRACOWNIK')
  1194. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'TELEFON')
  1195. )
  1196. begin
  1197. declare @CurrentUser sysname
  1198. select @CurrentUser = user_name()
  1199. execute sp_dropextendedproperty 'MS_Description',
  1200. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'TELEFON'
  1201.  
  1202. end
  1203.  
  1204.  
  1205. select @CurrentUser = user_name()
  1206. execute sp_addextendedproperty 'MS_Description',
  1207. 'telefon pracownika lub klienta',
  1208. 'user', @CurrentUser, 'table', 'PRACOWNIK', 'column', 'TELEFON'
  1209. go
  1210.  
  1211. /*==============================================================*/
  1212. /* Index: FK_OSOBA_ADRES_FK */
  1213. /*==============================================================*/
  1214. create index FK_OSOBA_ADRES_FK on PRACOWNIK (
  1215. ID_ADRES ASC
  1216. )
  1217. go
  1218.  
  1219. /*==============================================================*/
  1220. /* Table: WYPOZYCZENIE */
  1221. /*==============================================================*/
  1222. create table WYPOZYCZENIE (
  1223. ID_WYPOZYCZENIA int not null,
  1224. ID_FILMU int null,
  1225. ID_KLIENTA int not null,
  1226. PRA_ID_KLIENTA int not null,
  1227. DATA_WYPOZYCZENIA datetime not null,
  1228. DATA_ZWROTU datetime not null,
  1229. KWOTA_WYPOZYCZENIA float not null,
  1230. DATA_PLATNOSCI datetime not null,
  1231. constraint PK_WYPOZYCZENIE primary key nonclustered (ID_WYPOZYCZENIA)
  1232. )
  1233. go
  1234.  
  1235. if exists (select 1 from sys.extended_properties
  1236. where major_id = object_id('WYPOZYCZENIE') and minor_id = 0)
  1237. begin
  1238. declare @CurrentUser sysname
  1239. select @CurrentUser = user_name()
  1240. execute sp_dropextendedproperty 'MS_Description',
  1241. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE'
  1242.  
  1243. end
  1244.  
  1245.  
  1246. select @CurrentUser = user_name()
  1247. execute sp_addextendedproperty 'MS_Description',
  1248. 'przyporządkowanie filmu do klienta przy uzyciu pracownika',
  1249. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE'
  1250. go
  1251.  
  1252. if exists(select 1 from sys.extended_properties p where
  1253. p.major_id = object_id('WYPOZYCZENIE')
  1254. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_WYPOZYCZENIA')
  1255. )
  1256. begin
  1257. declare @CurrentUser sysname
  1258. select @CurrentUser = user_name()
  1259. execute sp_dropextendedproperty 'MS_Description',
  1260. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'ID_WYPOZYCZENIA'
  1261.  
  1262. end
  1263.  
  1264.  
  1265. select @CurrentUser = user_name()
  1266. execute sp_addextendedproperty 'MS_Description',
  1267. 'ID_WYPOZYCZENIA filmu przez klienta
  1268. ',
  1269. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'ID_WYPOZYCZENIA'
  1270. go
  1271.  
  1272. if exists(select 1 from sys.extended_properties p where
  1273. p.major_id = object_id('WYPOZYCZENIE')
  1274. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_FILMU')
  1275. )
  1276. begin
  1277. declare @CurrentUser sysname
  1278. select @CurrentUser = user_name()
  1279. execute sp_dropextendedproperty 'MS_Description',
  1280. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'ID_FILMU'
  1281.  
  1282. end
  1283.  
  1284.  
  1285. select @CurrentUser = user_name()
  1286. execute sp_addextendedproperty 'MS_Description',
  1287. 'ID wypozyczanego filmu ',
  1288. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'ID_FILMU'
  1289. go
  1290.  
  1291. if exists(select 1 from sys.extended_properties p where
  1292. p.major_id = object_id('WYPOZYCZENIE')
  1293. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ID_KLIENTA')
  1294. )
  1295. begin
  1296. declare @CurrentUser sysname
  1297. select @CurrentUser = user_name()
  1298. execute sp_dropextendedproperty 'MS_Description',
  1299. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'ID_KLIENTA'
  1300.  
  1301. end
  1302.  
  1303.  
  1304. select @CurrentUser = user_name()
  1305. execute sp_addextendedproperty 'MS_Description',
  1306. 'ID_KLIENTA',
  1307. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'ID_KLIENTA'
  1308. go
  1309.  
  1310. if exists(select 1 from sys.extended_properties p where
  1311. p.major_id = object_id('WYPOZYCZENIE')
  1312. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'PRA_ID_KLIENTA')
  1313. )
  1314. begin
  1315. declare @CurrentUser sysname
  1316. select @CurrentUser = user_name()
  1317. execute sp_dropextendedproperty 'MS_Description',
  1318. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'PRA_ID_KLIENTA'
  1319.  
  1320. end
  1321.  
  1322.  
  1323. select @CurrentUser = user_name()
  1324. execute sp_addextendedproperty 'MS_Description',
  1325. 'ID_KLIENTA',
  1326. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'PRA_ID_KLIENTA'
  1327. go
  1328.  
  1329. if exists(select 1 from sys.extended_properties p where
  1330. p.major_id = object_id('WYPOZYCZENIE')
  1331. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'DATA_WYPOZYCZENIA')
  1332. )
  1333. begin
  1334. declare @CurrentUser sysname
  1335. select @CurrentUser = user_name()
  1336. execute sp_dropextendedproperty 'MS_Description',
  1337. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'DATA_WYPOZYCZENIA'
  1338.  
  1339. end
  1340.  
  1341.  
  1342. select @CurrentUser = user_name()
  1343. execute sp_addextendedproperty 'MS_Description',
  1344. 'kiedy film zostal wypozyczony',
  1345. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'DATA_WYPOZYCZENIA'
  1346. go
  1347.  
  1348. if exists(select 1 from sys.extended_properties p where
  1349. p.major_id = object_id('WYPOZYCZENIE')
  1350. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'DATA_ZWROTU')
  1351. )
  1352. begin
  1353. declare @CurrentUser sysname
  1354. select @CurrentUser = user_name()
  1355. execute sp_dropextendedproperty 'MS_Description',
  1356. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'DATA_ZWROTU'
  1357.  
  1358. end
  1359.  
  1360.  
  1361. select @CurrentUser = user_name()
  1362. execute sp_addextendedproperty 'MS_Description',
  1363. 'kiedy film zostal oddany lub ma byc oddany',
  1364. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'DATA_ZWROTU'
  1365. go
  1366.  
  1367. if exists(select 1 from sys.extended_properties p where
  1368. p.major_id = object_id('WYPOZYCZENIE')
  1369. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'KWOTA_WYPOZYCZENIA')
  1370. )
  1371. begin
  1372. declare @CurrentUser sysname
  1373. select @CurrentUser = user_name()
  1374. execute sp_dropextendedproperty 'MS_Description',
  1375. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'KWOTA_WYPOZYCZENIA'
  1376.  
  1377. end
  1378.  
  1379.  
  1380. select @CurrentUser = user_name()
  1381. execute sp_addextendedproperty 'MS_Description',
  1382. 'KWOTA JAKĄ MUSI ZAPŁACIC KLIENT ZA WYPOZYCZENIE',
  1383. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'KWOTA_WYPOZYCZENIA'
  1384. go
  1385.  
  1386. if exists(select 1 from sys.extended_properties p where
  1387. p.major_id = object_id('WYPOZYCZENIE')
  1388. and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'DATA_PLATNOSCI')
  1389. )
  1390. begin
  1391. declare @CurrentUser sysname
  1392. select @CurrentUser = user_name()
  1393. execute sp_dropextendedproperty 'MS_Description',
  1394. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'DATA_PLATNOSCI'
  1395.  
  1396. end
  1397.  
  1398.  
  1399. select @CurrentUser = user_name()
  1400. execute sp_addextendedproperty 'MS_Description',
  1401. 'KIEDY KLIENT ZAPLACI/ZAPLACI',
  1402. 'user', @CurrentUser, 'table', 'WYPOZYCZENIE', 'column', 'DATA_PLATNOSCI'
  1403. go
  1404.  
  1405. /*==============================================================*/
  1406. /* Index: FK_KLIENT_WYPOZYCZENIE_FK */
  1407. /*==============================================================*/
  1408. create index FK_KLIENT_WYPOZYCZENIE_FK on WYPOZYCZENIE (
  1409. ID_KLIENTA ASC
  1410. )
  1411. go
  1412.  
  1413. /*==============================================================*/
  1414. /* Index: FK_PRACOWNIK_WYPOZYCZENIE_FK */
  1415. /*==============================================================*/
  1416. create index FK_PRACOWNIK_WYPOZYCZENIE_FK on WYPOZYCZENIE (
  1417. PRA_ID_KLIENTA ASC
  1418. )
  1419. go
  1420.  
  1421. /*==============================================================*/
  1422. /* Index: fk_film_wypozyczenie_FK */
  1423. /*==============================================================*/
  1424. create index fk_film_wypozyczenie_FK on WYPOZYCZENIE (
  1425. ID_FILMU ASC
  1426. )
  1427. go
  1428.  
  1429.  
  1430. create trigger "CLR Trigger_adres" on ADRES insert as
  1431. external name %Assembly.GeneratedName%.
  1432. go
  1433.  
  1434.  
  1435. create trigger "CLR Trigger_klient" on KLIENT insert as
  1436. external name %Assembly.GeneratedName%.
  1437. go
  1438.  
  1439.  
  1440. create trigger "CLR Trigger_pracownik" on PRACOWNIK insert as
  1441. external name %Assembly.GeneratedName%.
  1442. go
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement