-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trafika_srcipt.sql
244 lines (244 loc) · 17.2 KB
/
Trafika_srcipt.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
USE [master]
GO
/****** Object: Database [Trafika] Script Date: 22-Dec-17 12:48:10 PM ******/
CREATE DATABASE [Trafika]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'Trafika', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\Trafika.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
LOG ON
( NAME = N'Trafika_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\Trafika_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
GO
ALTER DATABASE [Trafika] SET COMPATIBILITY_LEVEL = 140
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [Trafika].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [Trafika] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [Trafika] SET ANSI_NULLS OFF
GO
ALTER DATABASE [Trafika] SET ANSI_PADDING OFF
GO
ALTER DATABASE [Trafika] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [Trafika] SET ARITHABORT OFF
GO
ALTER DATABASE [Trafika] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [Trafika] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [Trafika] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [Trafika] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [Trafika] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [Trafika] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [Trafika] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [Trafika] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [Trafika] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [Trafika] SET DISABLE_BROKER
GO
ALTER DATABASE [Trafika] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [Trafika] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [Trafika] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [Trafika] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [Trafika] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [Trafika] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [Trafika] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [Trafika] SET RECOVERY SIMPLE
GO
ALTER DATABASE [Trafika] SET MULTI_USER
GO
ALTER DATABASE [Trafika] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [Trafika] SET DB_CHAINING OFF
GO
ALTER DATABASE [Trafika] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
ALTER DATABASE [Trafika] SET TARGET_RECOVERY_TIME = 60 SECONDS
GO
ALTER DATABASE [Trafika] SET DELAYED_DURABILITY = DISABLED
GO
ALTER DATABASE [Trafika] SET QUERY_STORE = OFF
GO
USE [Trafika]
GO
ALTER DATABASE SCOPED CONFIGURATION SET IDENTITY_CACHE = ON;
GO
ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION = OFF;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET LEGACY_CARDINALITY_ESTIMATION = PRIMARY;
GO
ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP = 0;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP = PRIMARY;
GO
ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SNIFFING = ON;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET PARAMETER_SNIFFING = PRIMARY;
GO
ALTER DATABASE SCOPED CONFIGURATION SET QUERY_OPTIMIZER_HOTFIXES = OFF;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET QUERY_OPTIMIZER_HOTFIXES = PRIMARY;
GO
USE [Trafika]
GO
/****** Object: Table [dbo].[tblDobavljac] Script Date: 22-Dec-17 12:48:10 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tblDobavljac](
[DobavljacID] [int] IDENTITY(1,1) NOT NULL,
[NazivFirme] [nvarchar](30) NULL,
CONSTRAINT [PK_tblDobavljac] PRIMARY KEY CLUSTERED
(
[DobavljacID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[tblFiskalniRacun] Script Date: 22-Dec-17 12:48:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tblFiskalniRacun](
[FiskalniRacunID] [int] IDENTITY(1,1) NOT NULL,
[DatumIzdavanja] [date] NULL,
[VremeIzdavanja] [nvarchar](10) NULL,
[MestoIzdavanja] [nvarchar](10) NULL,
[Iznos] [numeric](10, 2) NULL,
[Kolicina] [int] NULL,
[ProdavacID] [int] NULL,
[ProizvodID] [int] NULL,
[KupacID] [int] NULL,
CONSTRAINT [PK_tblFiskalniRacun] PRIMARY KEY CLUSTERED
(
[FiskalniRacunID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[tblKupac] Script Date: 22-Dec-17 12:48:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tblKupac](
[KupacID] [int] IDENTITY(1,1) NOT NULL,
[BrojMobilnogTelefona] [nvarchar](10) NULL,
CONSTRAINT [PK_tblKupac] PRIMARY KEY CLUSTERED
(
[KupacID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[tblProdavac] Script Date: 22-Dec-17 12:48:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tblProdavac](
[ProdavacID] [int] IDENTITY(1,1) NOT NULL,
[Username] [nvarchar](20) NULL,
[Password] [nvarchar](20) NULL,
CONSTRAINT [PK_tblProdavac] PRIMARY KEY CLUSTERED
(
[ProdavacID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[tblProizvod] Script Date: 22-Dec-17 12:48:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tblProizvod](
[ProizvodID] [int] IDENTITY(1,1) NOT NULL,
[Cena] [numeric](10, 2) NULL,
[Sifra] [nvarchar](20) NULL,
[Naziv] [nvarchar](20) NULL,
[ProizvodjacID] [int] NULL,
[VrstaProizvodaID] [int] NULL,
[DobavljacID] [int] NULL,
CONSTRAINT [PK_tblProizvod] PRIMARY KEY CLUSTERED
(
[ProizvodID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[tblProizvodjac] Script Date: 22-Dec-17 12:48:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tblProizvodjac](
[ProizvodjacID] [int] IDENTITY(1,1) NOT NULL,
[NazivProizvodjaca] [nvarchar](30) NULL,
CONSTRAINT [PK_tblProizvođač] PRIMARY KEY CLUSTERED
(
[ProizvodjacID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[tblVrstaProizvoda] Script Date: 22-Dec-17 12:48:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tblVrstaProizvoda](
[VrstaProizvodaID] [int] IDENTITY(1,1) NOT NULL,
[NazivVrsteProizvoda] [nvarchar](20) NULL,
CONSTRAINT [PK_tblVrstaProizvoda] PRIMARY KEY CLUSTERED
(
[VrstaProizvodaID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tblFiskalniRacun] WITH CHECK ADD CONSTRAINT [FK_tblFiskalniRacun_tblKupac] FOREIGN KEY([KupacID])
REFERENCES [dbo].[tblKupac] ([KupacID])
GO
ALTER TABLE [dbo].[tblFiskalniRacun] CHECK CONSTRAINT [FK_tblFiskalniRacun_tblKupac]
GO
ALTER TABLE [dbo].[tblFiskalniRacun] WITH CHECK ADD CONSTRAINT [FK_tblFiskalniRacun_tblProdavac] FOREIGN KEY([ProdavacID])
REFERENCES [dbo].[tblProdavac] ([ProdavacID])
GO
ALTER TABLE [dbo].[tblFiskalniRacun] CHECK CONSTRAINT [FK_tblFiskalniRacun_tblProdavac]
GO
ALTER TABLE [dbo].[tblFiskalniRacun] WITH CHECK ADD CONSTRAINT [FK_tblFiskalniRacun_tblProizvod] FOREIGN KEY([ProizvodID])
REFERENCES [dbo].[tblProizvod] ([ProizvodID])
GO
ALTER TABLE [dbo].[tblFiskalniRacun] CHECK CONSTRAINT [FK_tblFiskalniRacun_tblProizvod]
GO
ALTER TABLE [dbo].[tblProizvod] WITH CHECK ADD CONSTRAINT [FK_tblProizvod_tblDobavljac] FOREIGN KEY([DobavljacID])
REFERENCES [dbo].[tblDobavljac] ([DobavljacID])
GO
ALTER TABLE [dbo].[tblProizvod] CHECK CONSTRAINT [FK_tblProizvod_tblDobavljac]
GO
ALTER TABLE [dbo].[tblProizvod] WITH CHECK ADD CONSTRAINT [FK_tblProizvod_tblProizvodjac] FOREIGN KEY([ProizvodjacID])
REFERENCES [dbo].[tblProizvodjac] ([ProizvodjacID])
GO
ALTER TABLE [dbo].[tblProizvod] CHECK CONSTRAINT [FK_tblProizvod_tblProizvodjac]
GO
ALTER TABLE [dbo].[tblProizvod] WITH CHECK ADD CONSTRAINT [FK_tblProizvod_tblVrstaProizvoda] FOREIGN KEY([VrstaProizvodaID])
REFERENCES [dbo].[tblVrstaProizvoda] ([VrstaProizvodaID])
GO
ALTER TABLE [dbo].[tblProizvod] CHECK CONSTRAINT [FK_tblProizvod_tblVrstaProizvoda]
GO
USE [master]
GO
ALTER DATABASE [Trafika] SET READ_WRITE
GO