· 7 years ago · Dec 04, 2018, 08:08 AM
1/*==============================================================*/
2/* DBMS name: Microsoft SQL Server 2016 */
3/* Created on: 04/12/2018 09:05:19 */
4/*==============================================================*/
5
6
7if exists (select 1
8 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
9 where r.fkeyid = object_id('"Plany-grupy"') and o.name = 'FK_PLANY-GR_PLANY-GRU_PLANY_UC')
10alter table "Plany-grupy"
11 drop constraint "FK_PLANY-GR_PLANY-GRU_PLANY_UC"
12go
13
14if exists (select 1
15 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
16 where r.fkeyid = object_id('"Plany-grupy"') and o.name = 'FK_PLANY-GR_PLANY-GRU_GRUPY_DZ')
17alter table "Plany-grupy"
18 drop constraint "FK_PLANY-GR_PLANY-GRU_GRUPY_DZ"
19go
20
21if exists (select 1
22 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
23 where r.fkeyid = object_id('"Plany-przedmioty"') and o.name = 'FK_PLANY-PR_PLANY-PRZ_PLANY_UC')
24alter table "Plany-przedmioty"
25 drop constraint "FK_PLANY-PR_PLANY-PRZ_PLANY_UC"
26go
27
28if exists (select 1
29 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
30 where r.fkeyid = object_id('"Plany-przedmioty"') and o.name = 'FK_PLANY-PR_PLANY-PRZ_PRZEDMIO')
31alter table "Plany-przedmioty"
32 drop constraint "FK_PLANY-PR_PLANY-PRZ_PRZEDMIO"
33go
34
35if exists (select 1
36 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
37 where r.fkeyid = object_id('"Plany-specjalnosci"') and o.name = 'FK_PLANY-SP_PLANY-SPE_PLANY_UC')
38alter table "Plany-specjalnosci"
39 drop constraint "FK_PLANY-SP_PLANY-SPE_PLANY_UC"
40go
41
42if exists (select 1
43 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
44 where r.fkeyid = object_id('"Plany-specjalnosci"') and o.name = 'FK_PLANY-SP_PLANY-SPE_SPECJALN')
45alter table "Plany-specjalnosci"
46 drop constraint "FK_PLANY-SP_PLANY-SPE_SPECJALN"
47go
48
49if exists (select 1
50 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
51 where r.fkeyid = object_id('Pracownicy') and o.name = 'FK_PRACOWNI_KATEGORIE_KATEGORI')
52alter table Pracownicy
53 drop constraint FK_PRACOWNI_KATEGORIE_KATEGORI
54go
55
56if exists (select 1
57 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
58 where r.fkeyid = object_id('Pracownicy') and o.name = 'FK_PRACOWNI_UZYTKOWNI_UZYTKOWN')
59alter table Pracownicy
60 drop constraint FK_PRACOWNI_UZYTKOWNI_UZYTKOWN
61go
62
63if exists (select 1
64 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
65 where r.fkeyid = object_id('Przedmioty') and o.name = 'FK_PRZEDMIO_TRYBY-PRZ_TRYBY_ZA')
66alter table Przedmioty
67 drop constraint "FK_PRZEDMIO_TRYBY-PRZ_TRYBY_ZA"
68go
69
70if exists (select 1
71 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
72 where r.fkeyid = object_id('"Specjalnosci-przedmioty"') and o.name = 'FK_SPECJALN_SPECJALNO_SPECJALN')
73alter table "Specjalnosci-przedmioty"
74 drop constraint FK_SPECJALN_SPECJALNO_SPECJALN
75go
76
77if exists (select 1
78 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
79 where r.fkeyid = object_id('"Specjalnosci-przedmioty"') and o.name = 'FK_SPECJALN_SPECJALNO_PRZEDMIO')
80alter table "Specjalnosci-przedmioty"
81 drop constraint FK_SPECJALN_SPECJALNO_PRZEDMIO
82go
83
84if exists (select 1
85 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
86 where r.fkeyid = object_id('Studenci') and o.name = 'FK_STUDENCI_GRUPY-STU_GRUPY_DZ')
87alter table Studenci
88 drop constraint "FK_STUDENCI_GRUPY-STU_GRUPY_DZ"
89go
90
91if exists (select 1
92 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
93 where r.fkeyid = object_id('Studenci') and o.name = 'FK_STUDENCI_STUDENCI-_SPECJALN')
94alter table Studenci
95 drop constraint "FK_STUDENCI_STUDENCI-_SPECJALN"
96go
97
98if exists (select 1
99 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
100 where r.fkeyid = object_id('Studenci') and o.name = 'FK_STUDENCI_UZYTKOWNI_UZYTKOWN')
101alter table Studenci
102 drop constraint FK_STUDENCI_UZYTKOWNI_UZYTKOWN
103go
104
105if exists (select 1
106 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
107 where r.fkeyid = object_id('Studenci') and o.name = 'FK_STUDENCI_WYDZIALY-_WYDZIALY')
108alter table Studenci
109 drop constraint "FK_STUDENCI_WYDZIALY-_WYDZIALY"
110go
111
112if exists (select 1
113 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
114 where r.fkeyid = object_id('Uzytkownicy') and o.name = 'FK_UZYTKOWN_UZYTKOWNI_PRACOWNI')
115alter table Uzytkownicy
116 drop constraint FK_UZYTKOWN_UZYTKOWNI_PRACOWNI
117go
118
119if exists (select 1
120 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
121 where r.fkeyid = object_id('Uzytkownicy') and o.name = 'FK_UZYTKOWN_UZYTKOWNI_STUDENCI')
122alter table Uzytkownicy
123 drop constraint FK_UZYTKOWN_UZYTKOWNI_STUDENCI
124go
125
126if exists (select 1
127 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
128 where r.fkeyid = object_id('Uzytkownicy') and o.name = 'FK_UZYTKOWN_WYKLADOWC_WYKLADOW')
129alter table Uzytkownicy
130 drop constraint FK_UZYTKOWN_WYKLADOWC_WYKLADOW
131go
132
133if exists (select 1
134 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
135 where r.fkeyid = object_id('Wykladowcy') and o.name = 'FK_WYKLADOW_KATEGORIE_KATEGORI')
136alter table Wykladowcy
137 drop constraint FK_WYKLADOW_KATEGORIE_KATEGORI
138go
139
140if exists (select 1
141 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
142 where r.fkeyid = object_id('Wykladowcy') and o.name = 'FK_WYKLADOW_PLANY-WYK_PLANY_UC')
143alter table Wykladowcy
144 drop constraint "FK_WYKLADOW_PLANY-WYK_PLANY_UC"
145go
146
147if exists (select 1
148 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
149 where r.fkeyid = object_id('Wykladowcy') and o.name = 'FK_WYKLADOW_TYTULY-WY_TYTULY_N')
150alter table Wykladowcy
151 drop constraint "FK_WYKLADOW_TYTULY-WY_TYTULY_N"
152go
153
154if exists (select 1
155 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
156 where r.fkeyid = object_id('Wykladowcy') and o.name = 'FK_WYKLADOW_WYDZIALY-_WYDZIALY')
157alter table Wykladowcy
158 drop constraint "FK_WYKLADOW_WYDZIALY-_WYDZIALY"
159go
160
161if exists (select 1
162 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
163 where r.fkeyid = object_id('Wykladowcy') and o.name = 'FK_WYKLADOW_WYKLADOWC_UZYTKOWN')
164alter table Wykladowcy
165 drop constraint FK_WYKLADOW_WYKLADOWC_UZYTKOWN
166go
167
168if exists (select 1
169 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
170 where r.fkeyid = object_id('"Wykladowcy-przedmioty"') and o.name = 'FK_WYKLADOW_WYKLADOWC_WYKLADOW')
171alter table "Wykladowcy-przedmioty"
172 drop constraint FK_WYKLADOW_WYKLADOWC_WYKLADOW
173go
174
175if exists (select 1
176 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
177 where r.fkeyid = object_id('"Wykladowcy-przedmioty"') and o.name = 'FK_WYKLADOW_WYKLADOWC_PRZEDMIO')
178alter table "Wykladowcy-przedmioty"
179 drop constraint FK_WYKLADOW_WYKLADOWC_PRZEDMIO
180go
181
182if exists (select 1
183 from sysobjects
184 where id = object_id('Grupy_Dziekanskie')
185 and type = 'U')
186 drop table Grupy_Dziekanskie
187go
188
189if exists (select 1
190 from sysobjects
191 where id = object_id('Kategorie_Pracownikow')
192 and type = 'U')
193 drop table Kategorie_Pracownikow
194go
195
196if exists (select 1
197 from sysobjects
198 where id = object_id('Kategorie_Wykladowcow')
199 and type = 'U')
200 drop table Kategorie_Wykladowcow
201go
202
203if exists (select 1
204 from sysindexes
205 where id = object_id('"Plany-grupy"')
206 and name = 'PLANY_GRUPY2_FK'
207 and indid > 0
208 and indid < 255)
209 drop index "Plany-grupy".PLANY_GRUPY2_FK
210go
211
212if exists (select 1
213 from sysindexes
214 where id = object_id('"Plany-grupy"')
215 and name = 'PLANY_GRUPY_FK'
216 and indid > 0
217 and indid < 255)
218 drop index "Plany-grupy".PLANY_GRUPY_FK
219go
220
221if exists (select 1
222 from sysobjects
223 where id = object_id('"Plany-grupy"')
224 and type = 'U')
225 drop table "Plany-grupy"
226go
227
228if exists (select 1
229 from sysindexes
230 where id = object_id('"Plany-przedmioty"')
231 and name = 'PLANY_PRZEDMIOTY2_FK'
232 and indid > 0
233 and indid < 255)
234 drop index "Plany-przedmioty".PLANY_PRZEDMIOTY2_FK
235go
236
237if exists (select 1
238 from sysindexes
239 where id = object_id('"Plany-przedmioty"')
240 and name = 'PLANY_PRZEDMIOTY_FK'
241 and indid > 0
242 and indid < 255)
243 drop index "Plany-przedmioty".PLANY_PRZEDMIOTY_FK
244go
245
246if exists (select 1
247 from sysobjects
248 where id = object_id('"Plany-przedmioty"')
249 and type = 'U')
250 drop table "Plany-przedmioty"
251go
252
253if exists (select 1
254 from sysindexes
255 where id = object_id('"Plany-specjalnosci"')
256 and name = 'PLANY_SPECJALNOSCI2_FK'
257 and indid > 0
258 and indid < 255)
259 drop index "Plany-specjalnosci".PLANY_SPECJALNOSCI2_FK
260go
261
262if exists (select 1
263 from sysindexes
264 where id = object_id('"Plany-specjalnosci"')
265 and name = 'PLANY_SPECJALNOSCI_FK'
266 and indid > 0
267 and indid < 255)
268 drop index "Plany-specjalnosci".PLANY_SPECJALNOSCI_FK
269go
270
271if exists (select 1
272 from sysobjects
273 where id = object_id('"Plany-specjalnosci"')
274 and type = 'U')
275 drop table "Plany-specjalnosci"
276go
277
278if exists (select 1
279 from sysobjects
280 where id = object_id('Plany_Uczelniane')
281 and type = 'U')
282 drop table Plany_Uczelniane
283go
284
285if exists (select 1
286 from sysindexes
287 where id = object_id('Pracownicy')
288 and name = 'UZYTKOWNICY_PRACOWNICY2_FK'
289 and indid > 0
290 and indid < 255)
291 drop index Pracownicy.UZYTKOWNICY_PRACOWNICY2_FK
292go
293
294if exists (select 1
295 from sysindexes
296 where id = object_id('Pracownicy')
297 and name = 'KATEGORIE_PRACOWNICY_FK'
298 and indid > 0
299 and indid < 255)
300 drop index Pracownicy.KATEGORIE_PRACOWNICY_FK
301go
302
303if exists (select 1
304 from sysobjects
305 where id = object_id('Pracownicy')
306 and type = 'U')
307 drop table Pracownicy
308go
309
310if exists (select 1
311 from sysindexes
312 where id = object_id('Przedmioty')
313 and name = 'TRYBY_PRZEDMIOTY_FK'
314 and indid > 0
315 and indid < 255)
316 drop index Przedmioty.TRYBY_PRZEDMIOTY_FK
317go
318
319if exists (select 1
320 from sysobjects
321 where id = object_id('Przedmioty')
322 and type = 'U')
323 drop table Przedmioty
324go
325
326if exists (select 1
327 from sysobjects
328 where id = object_id('Specjalnosci')
329 and type = 'U')
330 drop table Specjalnosci
331go
332
333if exists (select 1
334 from sysindexes
335 where id = object_id('"Specjalnosci-przedmioty"')
336 and name = 'SPECJALNOSCI_PRZEDMIOTY2_FK'
337 and indid > 0
338 and indid < 255)
339 drop index "Specjalnosci-przedmioty".SPECJALNOSCI_PRZEDMIOTY2_FK
340go
341
342if exists (select 1
343 from sysindexes
344 where id = object_id('"Specjalnosci-przedmioty"')
345 and name = 'SPECJALNOSCI_PRZEDMIOTY_FK'
346 and indid > 0
347 and indid < 255)
348 drop index "Specjalnosci-przedmioty".SPECJALNOSCI_PRZEDMIOTY_FK
349go
350
351if exists (select 1
352 from sysobjects
353 where id = object_id('"Specjalnosci-przedmioty"')
354 and type = 'U')
355 drop table "Specjalnosci-przedmioty"
356go
357
358if exists (select 1
359 from sysindexes
360 where id = object_id('Studenci')
361 and name = 'UZYTKOWNICY_STUDENCI2_FK'
362 and indid > 0
363 and indid < 255)
364 drop index Studenci.UZYTKOWNICY_STUDENCI2_FK
365go
366
367if exists (select 1
368 from sysindexes
369 where id = object_id('Studenci')
370 and name = 'WYDZIALY_STUDENCI_FK'
371 and indid > 0
372 and indid < 255)
373 drop index Studenci.WYDZIALY_STUDENCI_FK
374go
375
376if exists (select 1
377 from sysindexes
378 where id = object_id('Studenci')
379 and name = 'STUDENCI_SPECJALNOSCI_FK'
380 and indid > 0
381 and indid < 255)
382 drop index Studenci.STUDENCI_SPECJALNOSCI_FK
383go
384
385if exists (select 1
386 from sysindexes
387 where id = object_id('Studenci')
388 and name = 'GRUPY_STUDENCI_FK'
389 and indid > 0
390 and indid < 255)
391 drop index Studenci.GRUPY_STUDENCI_FK
392go
393
394if exists (select 1
395 from sysobjects
396 where id = object_id('Studenci')
397 and type = 'U')
398 drop table Studenci
399go
400
401if exists (select 1
402 from sysobjects
403 where id = object_id('Tryby_Zajec')
404 and type = 'U')
405 drop table Tryby_Zajec
406go
407
408if exists (select 1
409 from sysobjects
410 where id = object_id('Tytuly_Naukowe')
411 and type = 'U')
412 drop table Tytuly_Naukowe
413go
414
415if exists (select 1
416 from sysindexes
417 where id = object_id('Uzytkownicy')
418 and name = 'UZYTKOWNICY_STUDENCI_FK'
419 and indid > 0
420 and indid < 255)
421 drop index Uzytkownicy.UZYTKOWNICY_STUDENCI_FK
422go
423
424if exists (select 1
425 from sysindexes
426 where id = object_id('Uzytkownicy')
427 and name = 'UZYTKOWNICY_PRACOWNICY_FK'
428 and indid > 0
429 and indid < 255)
430 drop index Uzytkownicy.UZYTKOWNICY_PRACOWNICY_FK
431go
432
433if exists (select 1
434 from sysindexes
435 where id = object_id('Uzytkownicy')
436 and name = 'WYKLADOWCY_UZYTKOWNICY2_FK'
437 and indid > 0
438 and indid < 255)
439 drop index Uzytkownicy.WYKLADOWCY_UZYTKOWNICY2_FK
440go
441
442if exists (select 1
443 from sysobjects
444 where id = object_id('Uzytkownicy')
445 and type = 'U')
446 drop table Uzytkownicy
447go
448
449if exists (select 1
450 from sysobjects
451 where id = object_id('Wydzialy')
452 and type = 'U')
453 drop table Wydzialy
454go
455
456if exists (select 1
457 from sysindexes
458 where id = object_id('Wykladowcy')
459 and name = 'WYKLADOWCY_UZYTKOWNICY_FK'
460 and indid > 0
461 and indid < 255)
462 drop index Wykladowcy.WYKLADOWCY_UZYTKOWNICY_FK
463go
464
465if exists (select 1
466 from sysindexes
467 where id = object_id('Wykladowcy')
468 and name = 'WYDZIALY_WYKLADOWCY_FK'
469 and indid > 0
470 and indid < 255)
471 drop index Wykladowcy.WYDZIALY_WYKLADOWCY_FK
472go
473
474if exists (select 1
475 from sysindexes
476 where id = object_id('Wykladowcy')
477 and name = 'TYTULY_WYKLADOWCY_FK'
478 and indid > 0
479 and indid < 255)
480 drop index Wykladowcy.TYTULY_WYKLADOWCY_FK
481go
482
483if exists (select 1
484 from sysindexes
485 where id = object_id('Wykladowcy')
486 and name = 'KATEGORIE_WYKLADOWCY_FK'
487 and indid > 0
488 and indid < 255)
489 drop index Wykladowcy.KATEGORIE_WYKLADOWCY_FK
490go
491
492if exists (select 1
493 from sysindexes
494 where id = object_id('Wykladowcy')
495 and name = 'PLANY_WYKLADOWCY_FK'
496 and indid > 0
497 and indid < 255)
498 drop index Wykladowcy.PLANY_WYKLADOWCY_FK
499go
500
501if exists (select 1
502 from sysobjects
503 where id = object_id('Wykladowcy')
504 and type = 'U')
505 drop table Wykladowcy
506go
507
508if exists (select 1
509 from sysindexes
510 where id = object_id('"Wykladowcy-przedmioty"')
511 and name = 'WYKLADOWCY_PRZEDMIOTY2_FK'
512 and indid > 0
513 and indid < 255)
514 drop index "Wykladowcy-przedmioty".WYKLADOWCY_PRZEDMIOTY2_FK
515go
516
517if exists (select 1
518 from sysindexes
519 where id = object_id('"Wykladowcy-przedmioty"')
520 and name = 'WYKLADOWCY_PRZEDMIOTY_FK'
521 and indid > 0
522 and indid < 255)
523 drop index "Wykladowcy-przedmioty".WYKLADOWCY_PRZEDMIOTY_FK
524go
525
526if exists (select 1
527 from sysobjects
528 where id = object_id('"Wykladowcy-przedmioty"')
529 and type = 'U')
530 drop table "Wykladowcy-przedmioty"
531go
532
533/*==============================================================*/
534/* Table: Grupy_Dziekanskie */
535/*==============================================================*/
536create table Grupy_Dziekanskie (
537 Gr_ID int not null,
538 Nazwa text not null,
539 constraint PK_GRUPY_DZIEKANSKIE primary key (Gr_ID)
540)
541go
542
543/*==============================================================*/
544/* Table: Kategorie_Pracownikow */
545/*==============================================================*/
546create table Kategorie_Pracownikow (
547 KategoriaP_ID int not null,
548 Nazwa text not null,
549 constraint PK_KATEGORIE_PRACOWNIKOW primary key (KategoriaP_ID)
550)
551go
552
553/*==============================================================*/
554/* Table: Kategorie_Wykladowcow */
555/*==============================================================*/
556create table Kategorie_Wykladowcow (
557 KategoriaW_ID int not null,
558 Nazwa text not null,
559 constraint PK_KATEGORIE_WYKLADOWCOW primary key (KategoriaW_ID)
560)
561go
562
563/*==============================================================*/
564/* Table: "Plany-grupy" */
565/*==============================================================*/
566create table "Plany-grupy" (
567 Plan_ID int null,
568 Gr_ID int null
569)
570go
571
572/*==============================================================*/
573/* Index: PLANY_GRUPY_FK */
574/*==============================================================*/
575
576
577
578
579create nonclustered index PLANY_GRUPY_FK on "Plany-grupy" (Plan_ID ASC)
580go
581
582/*==============================================================*/
583/* Index: PLANY_GRUPY2_FK */
584/*==============================================================*/
585
586
587
588
589create nonclustered index PLANY_GRUPY2_FK on "Plany-grupy" (Gr_ID ASC)
590go
591
592/*==============================================================*/
593/* Table: "Plany-przedmioty" */
594/*==============================================================*/
595create table "Plany-przedmioty" (
596 Plan_ID int null,
597 Przedmiot_ID int null
598)
599go
600
601/*==============================================================*/
602/* Index: PLANY_PRZEDMIOTY_FK */
603/*==============================================================*/
604
605
606
607
608create nonclustered index PLANY_PRZEDMIOTY_FK on "Plany-przedmioty" (Plan_ID ASC)
609go
610
611/*==============================================================*/
612/* Index: PLANY_PRZEDMIOTY2_FK */
613/*==============================================================*/
614
615
616
617
618create nonclustered index PLANY_PRZEDMIOTY2_FK on "Plany-przedmioty" (Przedmiot_ID ASC)
619go
620
621/*==============================================================*/
622/* Table: "Plany-specjalnosci" */
623/*==============================================================*/
624create table "Plany-specjalnosci" (
625 Plan_ID int null,
626 Specjalnosc_ID int null
627)
628go
629
630/*==============================================================*/
631/* Index: PLANY_SPECJALNOSCI_FK */
632/*==============================================================*/
633
634
635
636
637create nonclustered index PLANY_SPECJALNOSCI_FK on "Plany-specjalnosci" (Plan_ID ASC)
638go
639
640/*==============================================================*/
641/* Index: PLANY_SPECJALNOSCI2_FK */
642/*==============================================================*/
643
644
645
646
647create nonclustered index PLANY_SPECJALNOSCI2_FK on "Plany-specjalnosci" (Specjalnosc_ID ASC)
648go
649
650/*==============================================================*/
651/* Table: Plany_Uczelniane */
652/*==============================================================*/
653create table Plany_Uczelniane (
654 Plan_ID int not null,
655 constraint PK_PLANY_UCZELNIANE primary key (Plan_ID)
656)
657go
658
659/*==============================================================*/
660/* Table: Pracownicy */
661/*==============================================================*/
662create table Pracownicy (
663 Pracownik_ID int not null,
664 KategoriaP_ID int null,
665 User_ID int null,
666 Imie text not null,
667 Nazwisko text not null,
668 constraint PK_PRACOWNICY primary key (Pracownik_ID)
669)
670go
671
672/*==============================================================*/
673/* Index: KATEGORIE_PRACOWNICY_FK */
674/*==============================================================*/
675
676
677
678
679create nonclustered index KATEGORIE_PRACOWNICY_FK on Pracownicy (KategoriaP_ID ASC)
680go
681
682/*==============================================================*/
683/* Index: UZYTKOWNICY_PRACOWNICY2_FK */
684/*==============================================================*/
685
686
687
688
689create nonclustered index UZYTKOWNICY_PRACOWNICY2_FK on Pracownicy (User_ID ASC)
690go
691
692/*==============================================================*/
693/* Table: Przedmioty */
694/*==============================================================*/
695create table Przedmioty (
696 Przedmiot_ID int not null,
697 Tryb_ID int null,
698 Nazwa text not null,
699 Punkty_ECTS int not null,
700 constraint PK_PRZEDMIOTY primary key (Przedmiot_ID)
701)
702go
703
704/*==============================================================*/
705/* Index: TRYBY_PRZEDMIOTY_FK */
706/*==============================================================*/
707
708
709
710
711create nonclustered index TRYBY_PRZEDMIOTY_FK on Przedmioty (Tryb_ID ASC)
712go
713
714/*==============================================================*/
715/* Table: Specjalnosci */
716/*==============================================================*/
717create table Specjalnosci (
718 Specjalnosc_ID int not null,
719 Nazwa text not null,
720 constraint PK_SPECJALNOSCI primary key (Specjalnosc_ID)
721)
722go
723
724/*==============================================================*/
725/* Table: "Specjalnosci-przedmioty" */
726/*==============================================================*/
727create table "Specjalnosci-przedmioty" (
728 Specjalnosc_ID int null,
729 Przedmiot_ID int null
730)
731go
732
733/*==============================================================*/
734/* Index: SPECJALNOSCI_PRZEDMIOTY_FK */
735/*==============================================================*/
736
737
738
739
740create nonclustered index SPECJALNOSCI_PRZEDMIOTY_FK on "Specjalnosci-przedmioty" (Specjalnosc_ID ASC)
741go
742
743/*==============================================================*/
744/* Index: SPECJALNOSCI_PRZEDMIOTY2_FK */
745/*==============================================================*/
746
747
748
749
750create nonclustered index SPECJALNOSCI_PRZEDMIOTY2_FK on "Specjalnosci-przedmioty" (Przedmiot_ID ASC)
751go
752
753/*==============================================================*/
754/* Table: Studenci */
755/*==============================================================*/
756create table Studenci (
757 Student_ID int not null,
758 Gr_ID int null,
759 User_ID int null,
760 Wydzial_ID int null,
761 Specjalnosc_ID int null,
762 Imie text not null,
763 Nazwisko text not null,
764 Plec text null,
765 Rok_Urodzenia datetime null,
766 Wiek int null,
767 Obecnosc_Dzieci bit null,
768 Obecnosc_Stypendium bit null,
769 Wielkosc_Stypendium int null,
770 constraint PK_STUDENCI primary key (Student_ID)
771)
772go
773
774/*==============================================================*/
775/* Index: GRUPY_STUDENCI_FK */
776/*==============================================================*/
777
778
779
780
781create nonclustered index GRUPY_STUDENCI_FK on Studenci (Gr_ID ASC)
782go
783
784/*==============================================================*/
785/* Index: STUDENCI_SPECJALNOSCI_FK */
786/*==============================================================*/
787
788
789
790
791create nonclustered index STUDENCI_SPECJALNOSCI_FK on Studenci (Specjalnosc_ID ASC)
792go
793
794/*==============================================================*/
795/* Index: WYDZIALY_STUDENCI_FK */
796/*==============================================================*/
797
798
799
800
801create nonclustered index WYDZIALY_STUDENCI_FK on Studenci (Wydzial_ID ASC)
802go
803
804/*==============================================================*/
805/* Index: UZYTKOWNICY_STUDENCI2_FK */
806/*==============================================================*/
807
808
809
810
811create nonclustered index UZYTKOWNICY_STUDENCI2_FK on Studenci (User_ID ASC)
812go
813
814/*==============================================================*/
815/* Table: Tryby_Zajec */
816/*==============================================================*/
817create table Tryby_Zajec (
818 Tryb_ID int not null,
819 Nazwa text not null,
820 constraint PK_TRYBY_ZAJEC primary key (Tryb_ID)
821)
822go
823
824/*==============================================================*/
825/* Table: Tytuly_Naukowe */
826/*==============================================================*/
827create table Tytuly_Naukowe (
828 Tytul_ID int not null,
829 Nazwa text not null,
830 constraint PK_TYTULY_NAUKOWE primary key (Tytul_ID)
831)
832go
833
834/*==============================================================*/
835/* Table: Uzytkownicy */
836/*==============================================================*/
837create table Uzytkownicy (
838 User_ID int not null,
839 Wykladowca_ID int null,
840 Student_ID int null,
841 Pracownik_ID int null,
842 Login text not null,
843 Haslo text not null,
844 Uprawnienia text not null,
845 constraint PK_UZYTKOWNICY primary key (User_ID)
846)
847go
848
849/*==============================================================*/
850/* Index: WYKLADOWCY_UZYTKOWNICY2_FK */
851/*==============================================================*/
852
853
854
855
856create nonclustered index WYKLADOWCY_UZYTKOWNICY2_FK on Uzytkownicy (Wykladowca_ID ASC)
857go
858
859/*==============================================================*/
860/* Index: UZYTKOWNICY_PRACOWNICY_FK */
861/*==============================================================*/
862
863
864
865
866create nonclustered index UZYTKOWNICY_PRACOWNICY_FK on Uzytkownicy (Pracownik_ID ASC)
867go
868
869/*==============================================================*/
870/* Index: UZYTKOWNICY_STUDENCI_FK */
871/*==============================================================*/
872
873
874
875
876create nonclustered index UZYTKOWNICY_STUDENCI_FK on Uzytkownicy (Student_ID ASC)
877go
878
879/*==============================================================*/
880/* Table: Wydzialy */
881/*==============================================================*/
882create table Wydzialy (
883 Wydzial_ID int not null,
884 Nazwa text not null,
885 constraint PK_WYDZIALY primary key (Wydzial_ID)
886)
887go
888
889/*==============================================================*/
890/* Table: Wykladowcy */
891/*==============================================================*/
892create table Wykladowcy (
893 Wykladowca_ID int not null,
894 Tytul_ID int null,
895 Wydzial_ID int null,
896 KategoriaW_ID int null,
897 Plan_ID int null,
898 User_ID int null,
899 Imie text not null,
900 Nazwisko text not null,
901 Plec text null,
902 Pensja int not null,
903 constraint PK_WYKLADOWCY primary key (Wykladowca_ID)
904)
905go
906
907/*==============================================================*/
908/* Index: PLANY_WYKLADOWCY_FK */
909/*==============================================================*/
910
911
912
913
914create nonclustered index PLANY_WYKLADOWCY_FK on Wykladowcy (Plan_ID ASC)
915go
916
917/*==============================================================*/
918/* Index: KATEGORIE_WYKLADOWCY_FK */
919/*==============================================================*/
920
921
922
923
924create nonclustered index KATEGORIE_WYKLADOWCY_FK on Wykladowcy (KategoriaW_ID ASC)
925go
926
927/*==============================================================*/
928/* Index: TYTULY_WYKLADOWCY_FK */
929/*==============================================================*/
930
931
932
933
934create nonclustered index TYTULY_WYKLADOWCY_FK on Wykladowcy (Tytul_ID ASC)
935go
936
937/*==============================================================*/
938/* Index: WYDZIALY_WYKLADOWCY_FK */
939/*==============================================================*/
940
941
942
943
944create nonclustered index WYDZIALY_WYKLADOWCY_FK on Wykladowcy (Wydzial_ID ASC)
945go
946
947/*==============================================================*/
948/* Index: WYKLADOWCY_UZYTKOWNICY_FK */
949/*==============================================================*/
950
951
952
953
954create nonclustered index WYKLADOWCY_UZYTKOWNICY_FK on Wykladowcy (User_ID ASC)
955go
956
957/*==============================================================*/
958/* Table: "Wykladowcy-przedmioty" */
959/*==============================================================*/
960create table "Wykladowcy-przedmioty" (
961 Wykladowca_ID int null,
962 Przedmiot_ID int null
963)
964go
965
966/*==============================================================*/
967/* Index: WYKLADOWCY_PRZEDMIOTY_FK */
968/*==============================================================*/
969
970
971
972
973create nonclustered index WYKLADOWCY_PRZEDMIOTY_FK on "Wykladowcy-przedmioty" (Wykladowca_ID ASC)
974go
975
976/*==============================================================*/
977/* Index: WYKLADOWCY_PRZEDMIOTY2_FK */
978/*==============================================================*/
979
980
981
982
983create nonclustered index WYKLADOWCY_PRZEDMIOTY2_FK on "Wykladowcy-przedmioty" (Przedmiot_ID ASC)
984go
985
986alter table "Plany-grupy"
987 add constraint "FK_PLANY-GR_PLANY-GRU_PLANY_UC" foreign key (Plan_ID)
988 references Plany_Uczelniane (Plan_ID)
989go
990
991alter table "Plany-grupy"
992 add constraint "FK_PLANY-GR_PLANY-GRU_GRUPY_DZ" foreign key (Gr_ID)
993 references Grupy_Dziekanskie (Gr_ID)
994go
995
996alter table "Plany-przedmioty"
997 add constraint "FK_PLANY-PR_PLANY-PRZ_PLANY_UC" foreign key (Plan_ID)
998 references Plany_Uczelniane (Plan_ID)
999go
1000
1001alter table "Plany-przedmioty"
1002 add constraint "FK_PLANY-PR_PLANY-PRZ_PRZEDMIO" foreign key (Przedmiot_ID)
1003 references Przedmioty (Przedmiot_ID)
1004go
1005
1006alter table "Plany-specjalnosci"
1007 add constraint "FK_PLANY-SP_PLANY-SPE_PLANY_UC" foreign key (Plan_ID)
1008 references Plany_Uczelniane (Plan_ID)
1009go
1010
1011alter table "Plany-specjalnosci"
1012 add constraint "FK_PLANY-SP_PLANY-SPE_SPECJALN" foreign key (Specjalnosc_ID)
1013 references Specjalnosci (Specjalnosc_ID)
1014go
1015
1016alter table Pracownicy
1017 add constraint FK_PRACOWNI_KATEGORIE_KATEGORI foreign key (KategoriaP_ID)
1018 references Kategorie_Pracownikow (KategoriaP_ID)
1019go
1020
1021alter table Pracownicy
1022 add constraint FK_PRACOWNI_UZYTKOWNI_UZYTKOWN foreign key (User_ID)
1023 references Uzytkownicy (User_ID)
1024go
1025
1026alter table Przedmioty
1027 add constraint "FK_PRZEDMIO_TRYBY-PRZ_TRYBY_ZA" foreign key (Tryb_ID)
1028 references Tryby_Zajec (Tryb_ID)
1029go
1030
1031alter table "Specjalnosci-przedmioty"
1032 add constraint FK_SPECJALN_SPECJALNO_SPECJALN foreign key (Specjalnosc_ID)
1033 references Specjalnosci (Specjalnosc_ID)
1034go
1035
1036alter table "Specjalnosci-przedmioty"
1037 add constraint FK_SPECJALN_SPECJALNO_PRZEDMIO foreign key (Przedmiot_ID)
1038 references Przedmioty (Przedmiot_ID)
1039go
1040
1041alter table Studenci
1042 add constraint "FK_STUDENCI_GRUPY-STU_GRUPY_DZ" foreign key (Gr_ID)
1043 references Grupy_Dziekanskie (Gr_ID)
1044go
1045
1046alter table Studenci
1047 add constraint "FK_STUDENCI_STUDENCI-_SPECJALN" foreign key (Specjalnosc_ID)
1048 references Specjalnosci (Specjalnosc_ID)
1049go
1050
1051alter table Studenci
1052 add constraint FK_STUDENCI_UZYTKOWNI_UZYTKOWN foreign key (User_ID)
1053 references Uzytkownicy (User_ID)
1054go
1055
1056alter table Studenci
1057 add constraint "FK_STUDENCI_WYDZIALY-_WYDZIALY" foreign key (Wydzial_ID)
1058 references Wydzialy (Wydzial_ID)
1059go
1060
1061alter table Uzytkownicy
1062 add constraint FK_UZYTKOWN_UZYTKOWNI_PRACOWNI foreign key (Pracownik_ID)
1063 references Pracownicy (Pracownik_ID)
1064go
1065
1066alter table Uzytkownicy
1067 add constraint FK_UZYTKOWN_UZYTKOWNI_STUDENCI foreign key (Student_ID)
1068 references Studenci (Student_ID)
1069go
1070
1071alter table Uzytkownicy
1072 add constraint FK_UZYTKOWN_WYKLADOWC_WYKLADOW foreign key (Wykladowca_ID)
1073 references Wykladowcy (Wykladowca_ID)
1074go
1075
1076alter table Wykladowcy
1077 add constraint FK_WYKLADOW_KATEGORIE_KATEGORI foreign key (KategoriaW_ID)
1078 references Kategorie_Wykladowcow (KategoriaW_ID)
1079go
1080
1081alter table Wykladowcy
1082 add constraint "FK_WYKLADOW_PLANY-WYK_PLANY_UC" foreign key (Plan_ID)
1083 references Plany_Uczelniane (Plan_ID)
1084go
1085
1086alter table Wykladowcy
1087 add constraint "FK_WYKLADOW_TYTULY-WY_TYTULY_N" foreign key (Tytul_ID)
1088 references Tytuly_Naukowe (Tytul_ID)
1089go
1090
1091alter table Wykladowcy
1092 add constraint "FK_WYKLADOW_WYDZIALY-_WYDZIALY" foreign key (Wydzial_ID)
1093 references Wydzialy (Wydzial_ID)
1094go
1095
1096alter table Wykladowcy
1097 add constraint FK_WYKLADOW_WYKLADOWC_UZYTKOWN foreign key (User_ID)
1098 references Uzytkownicy (User_ID)
1099go
1100
1101alter table "Wykladowcy-przedmioty"
1102 add constraint FK_WYKLADOW_WYKLADOWC_WYKLADOW foreign key (Wykladowca_ID)
1103 references Wykladowcy (Wykladowca_ID)
1104go
1105
1106alter table "Wykladowcy-przedmioty"
1107 add constraint FK_WYKLADOW_WYKLADOWC_PRZEDMIO foreign key (Przedmiot_ID)
1108 references Przedmioty (Przedmiot_ID)
1109go