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