· 5 years ago · Nov 10, 2020, 07:20 PM
1/*==============================================================*/
2/* DBMS name: Microsoft SQL Server 2008 */
3/* Created on: 10.11.2020 20:08:57 */
4/*==============================================================*/
5
6
7if exists (select 1
8 from sysobjects
9 where id = object_id('Grupa')
10 and type = 'U')
11 drop table Grupa
12go
13
14if exists (select 1
15 from sysindexes
16 where id = object_id('kontakt')
17 and name = 'Relationship_1_FK'
18 and indid > 0
19 and indid < 255)
20 drop index kontakt.Relationship_1_FK
21go
22
23if exists (select 1
24 from sysobjects
25 where id = object_id('kontakt')
26 and type = 'U')
27 drop table kontakt
28go
29
30/*==============================================================*/
31/* Table: Grupa */
32/*==============================================================*/
33create table Grupa (
34 Id_grupa int not null,
35 Nazwa_grupa varchar(50) not null,
36 constraint PK_GRUPA primary key nonclustered (Id_grupa)
37)
38go
39
40/*==============================================================*/
41/* Table: kontakt */
42/*==============================================================*/
43create table kontakt (
44 Id_kontakt int not null,
45 Id_grupa int not null,
46 Imie varchar(50) not null,
47 Nazwisko varchar(50) not null,
48 Adres_1 varchar(150) not null,
49 Adres_2 char(6) not null,
50 Adres_3 varchar(100) not null,
51 Telefon varchar(20) null,
52 Mobile varchar(20) not null,
53 Email varchar(100) not null,
54 constraint PK_KONTAKT primary key nonclustered (Id_kontakt)
55)
56go
57
58/*==============================================================*/
59/* Index: Relationship_1_FK */
60/*==============================================================*/
61create index Relationship_1_FK on kontakt (
62Id_grupa ASC
63)
64go
65
66