· 5 years ago · Nov 10, 2020, 07:32 PM
1/*==============================================================*/
2/* DBMS name: Microsoft SQL Server 2000 */
3/* Created on: 24.10.2020 15:06:13 */
4/*==============================================================*/
5
6
7if exists (select 1
8 from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
9 where r.fkeyid = object_id('KONTAKT') and o.name = 'FK_KONTAKT_RELATIONS_GRUPA')
10alter table KONTAKT
11 drop constraint FK_KONTAKT_RELATIONS_GRUPA
12go
13
14if exists (select 1
15 from sysobjects
16 where id = object_id('GRUPA')
17 and type = 'U')
18 drop table GRUPA
19go
20
21if exists (select 1
22 from sysindexes
23 where id = object_id('KONTAKT')
24 and name = 'RELATIONSHIP_1_FK'
25 and indid > 0
26 and indid < 255)
27 drop index KONTAKT.RELATIONSHIP_1_FK
28go
29
30if exists (select 1
31 from sysobjects
32 where id = object_id('KONTAKT')
33 and type = 'U')
34 drop table KONTAKT
35go
36
37/*==============================================================*/
38/* Table: GRUPA */
39/*==============================================================*/
40create table GRUPA (
41 ID_GRUPA int not null,
42 NAZWA_GRUPY varchar(50) not null,
43 constraint PK_GRUPA primary key nonclustered (ID_GRUPA)
44)
45go
46
47/*==============================================================*/
48/* Table: KONTAKT */
49/*==============================================================*/
50create table KONTAKT (
51 ID_KONTAKT int not null,
52 ID_GRUPA int not null,
53 IMIE varchar(50) not null,
54 NAZWISKO varchar(50) not null,
55 ADRES_1 varchar(150) not null,
56 ADRES_2 char(6) not null,
57 ADRES_3 varchar(50) not null,
58 TELEFON varchar(20) null,
59 MOBILE varchar(20) not null,
60 EMAIL varchar(100) not null,
61 constraint PK_KONTAKT primary key nonclustered (ID_KONTAKT)
62)
63go
64
65/*==============================================================*/
66/* Index: RELATIONSHIP_1_FK */
67/*==============================================================*/
68create index RELATIONSHIP_1_FK on KONTAKT (
69ID_GRUPA ASC
70)
71go
72
73alter table KONTAKT
74 add constraint FK_KONTAKT_RELATIONS_GRUPA foreign key (ID_GRUPA)
75 references GRUPA (ID_GRUPA)
76go
77
78