-
Notifications
You must be signed in to change notification settings - Fork 0
/
creation.sql
198 lines (170 loc) · 5.1 KB
/
creation.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
CREATE DATABASE KargoDb
ON PRIMARY (
NAME='KargoDb',
FILENAME = 'C:\database\KargoDb.mdf',
SIZE = 10MB,
MAXSIZE = 250MB,
FILEGROWTH = 10MB
)
LOG ON (
NAME = 'KargoLog',
FILENAME = 'C:\database\KargoLog.ldf' ,
SIZE = 2MB,
MAXSIZE = 50MB,
FILEGROWTH = 1MB
)
GO
USE KargoDb
GO
CREATE TABLE tblUrunKategorisi
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Kg_Fiyat DECIMAL NOT NULL,
Kategori_Tipi VARCHAR(100) NOT NULL,
Desi_Fiyat DECIMAL NOT NULL,
)
GO
CREATE TABLE tblMusteri
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Ad VARCHAR(50) NOT NULL,
Soyad VARCHAR(50) NOT NULL,
Mail VARCHAR(100) NOT NULL CONSTRAINT checkMailMusteri Check (Mail Like '%@%.%'),
Dogum_Tarihi DATE NOT NULL,
Cinsiyet VARCHAR(15) NOT NULL,
Telno VARCHAR(16) NOT NULL CONSTRAINT checkTelMusteri Check (Telno Like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'),
TC VARCHAR(11) UNIQUE NOT NULL CONSTRAINT checkTCMusteri Check (TC Like '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'),
)
GO
CREATE TABLE tblUlke
(
ID TINYINT IDENTITY(1,1) PRIMARY KEY,
Ulke VARCHAR(100) NOT NULL,
)
GO
CREATE TABLE tblSehir
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Sehir VARCHAR(100) NOT NULL,
UlkeId TINYINT FOREIGN KEY REFERENCES tblUlke(ID)
)
GO
CREATE TABLE tblIlce
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Ilce VARCHAR(100) NOT NULL,
SehirId INT FOREIGN KEY REFERENCES tblSehir(ID)
)
GO
CREATE TABLE tblMahalle
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Mahalle VARCHAR(100) NOT NULL,
IlceId INT FOREIGN KEY REFERENCES tblIlce(ID)
)
GO
CREATE TABLE tblAdres
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Postakodu VARCHAR(7) NOT NULL,
Acik_adres VARCHAR(500) NOT NULL,
UlkeId TINYINT FOREIGN KEY REFERENCES tblUlke(ID) NOT NULL,
SehirId INT FOREIGN KEY REFERENCES tblSehir(ID) NOT NULL,
IlceId INT FOREIGN KEY REFERENCES tblIlce(ID) NOT NULL,
MahalleId INT FOREIGN KEY REFERENCES tblMahalle(ID) NOT NULL,
MusteriId INT FOREIGN KEY REFERENCES tblMusteri(ID),
)
GO
CREATE TABLE tblSube
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Sube_Kodu VARCHAR(50) UNIQUE NOT NULL,
Telno VARCHAR(16) NOT NULL CONSTRAINT checkTelSube Check (Telno Like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'),
AdresId INT FOREIGN KEY REFERENCES tblAdres(ID) NOT NULL
)
GO
CREATE TABLE tblCalisan
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Ad VARCHAR(50) NOT NULL,
Soyad VARCHAR(50) NOT NULL,
Mail VARCHAR(100) NOT NULL CONSTRAINT checkMailCalisan Check (Mail Like '%@%.%'),
Dogum_Tarihi DATE NOT NULL,
Cinsiyet VARCHAR(15) NOT NULL,
Telno VARCHAR(16) NOT NULL CONSTRAINT checkTelCalisan Check (Telno Like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'),
TC VARCHAR(11) UNIQUE NOT NULL CONSTRAINT checkTCCalisan Check (TC Like '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'),
SubeId INT FOREIGN KEY REFERENCES tblSube(ID) NOT NULL
)
GO
CREATE TABLE tblArac
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Plaka VARCHAR(10) NOT NULL
)
GO
CREATE TABLE tblOdemeTipi
(
ID TINYINT IDENTITY(1,1) PRIMARY KEY,
Tip VARCHAR(50) NOT NULL
)
GO
CREATE TABLE tblKargoDurumu
(
ID TINYINT IDENTITY(1,1) PRIMARY KEY,
Durum VARCHAR(50) NOT NULL
)
GO
CREATE TABLE tblGeridonut
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Tarih DATE NOT NULL,
Icerik VARCHAR(500) NOT NULL,
MusteriId INT FOREIGN KEY REFERENCES tblMusteri(Id) NOT NULL
)
GO
CREATE TABLE tblKargo
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Teslim_Alým_Tarihi DATE NOT NULL DEFAULT GETDATE(),
Teslim_Edilme_Tarihi DATE NOT NULL,
Barkod_Numarasý VARCHAR(200) NOT NULL,
Toplam_Ucret INT NOT NULL,
CikisAdresId INT FOREIGN KEY REFERENCES tblAdres(ID) NOT NULL,
VarisAdresId INT FOREIGN KEY REFERENCES tblAdres(ID) NOT NULL,
OdemeTipiId TINYINT FOREIGN KEY REFERENCES tblOdemeTipi(ID) NOT NULL,
TeslimAlanCalisanId INT FOREIGN KEY REFERENCES tblCalisan(ID) NOT NULL,
VarisSubeId INT FOREIGN KEY REFERENCES tblSube(ID) NOT NULL,
AlisSubeId INT FOREIGN KEY REFERENCES tblSube(ID) NOT NULL,
KargoSonDurumId TINYINT FOREIGN KEY REFERENCES tblKargoDurumu(ID) NOT NULL,
TeslimAlanMusteriId INT FOREIGN KEY REFERENCES tblMusteri(ID) NOT NULL,
GönderenMusteriId INT FOREIGN KEY REFERENCES tblMusteri(ID) NOT NULL,
GeriDonutId INT FOREIGN KEY REFERENCES tblGeriDonut(ID)
)
GO
CREATE TABLE tblUrun
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Kg DECIMAL NOT NULL,
En DECIMAL NOT NULL,
Fiyat DECIMAL NOT NULL,
Desi DECIMAL NOT NULL,
Boy DECIMAL NOT NULL,
Yukseklik DECIMAL NOT NULL,
UrunKategoriId INT FOREIGN KEY REFERENCES tblUrunKategorisi(ID) NOT NULL,
KargoId INT FOREIGN KEY REFERENCES tblKargo(Id)
)
GO
CREATE TABLE tblKargoHareketleri
(
ID INT IDENTITY(1,1) PRIMARY KEY,
CikisTarihi DATE NOT NULL DEFAULT GETDATE(),
VarisTarihi DATE NOT NULL,
CikisSaati TIME,
VarisSaati TIME,
AracId INT FOREIGN KEY REFERENCES tblArac(Id),
VarisSubeId INT FOREIGN KEY REFERENCES tblSube(Id),
CikisSubeId INT FOREIGN KEY REFERENCES tblSube(Id),
KargoDurumId TINYINT FOREIGN KEY REFERENCES tblKargoDurumu(Id),
KargoId INT FOREIGN KEY REFERENCES tblKargo(Id),
)
GO