-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestauracjaModel.edmx.sql
More file actions
164 lines (140 loc) · 4.4 KB
/
RestauracjaModel.edmx.sql
File metadata and controls
164 lines (140 loc) · 4.4 KB
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
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 01/23/2022 19:07:22
-- Generated from EDMX file: C:\Users\Vorox\source\repos\ProjektIO\Restauracja\RestauracjaModel.edmx
-- --------------------------------------------------
SET QUOTED_IDENTIFIER OFF;
GO
USE [RestauracjaDB];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO
-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------
IF OBJECT_ID(N'[dbo].[FK_OrderTable]', 'F') IS NOT NULL
ALTER TABLE [dbo].[TableSet] DROP CONSTRAINT [FK_OrderTable];
GO
IF OBJECT_ID(N'[dbo].[FK_OrderItem]', 'F') IS NOT NULL
ALTER TABLE [dbo].[ItemSet] DROP CONSTRAINT [FK_OrderItem];
GO
IF OBJECT_ID(N'[dbo].[FK_MenuItem]', 'F') IS NOT NULL
ALTER TABLE [dbo].[ItemSet] DROP CONSTRAINT [FK_MenuItem];
GO
-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------
IF OBJECT_ID(N'[dbo].[TableSet]', 'U') IS NOT NULL
DROP TABLE [dbo].[TableSet];
GO
IF OBJECT_ID(N'[dbo].[ItemSet]', 'U') IS NOT NULL
DROP TABLE [dbo].[ItemSet];
GO
IF OBJECT_ID(N'[dbo].[OrderSet]', 'U') IS NOT NULL
DROP TABLE [dbo].[OrderSet];
GO
IF OBJECT_ID(N'[dbo].[MenuSet]', 'U') IS NOT NULL
DROP TABLE [dbo].[MenuSet];
GO
-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------
-- Creating table 'TableSet'
CREATE TABLE [dbo].[TableSet] (
[Id] int IDENTITY(1,1) NOT NULL,
[table_status] int NOT NULL,
[people] int NOT NULL,
[Order_Id] int NULL
);
GO
-- Creating table 'ItemSet'
CREATE TABLE [dbo].[ItemSet] (
[Id] int IDENTITY(1,1) NOT NULL,
[Order_Id] int NOT NULL,
[Menu_Id] int NOT NULL
);
GO
-- Creating table 'OrderSet'
CREATE TABLE [dbo].[OrderSet] (
[Id] int IDENTITY(1,1) NOT NULL,
[time] datetime NOT NULL,
[is_finished] bit NOT NULL
);
GO
-- Creating table 'MenuSet'
CREATE TABLE [dbo].[MenuSet] (
[Id] int IDENTITY(1,1) NOT NULL,
[name] nvarchar(max) NOT NULL,
[picture] nvarchar(max) NOT NULL,
[price] float NOT NULL
);
GO
-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------
-- Creating primary key on [Id] in table 'TableSet'
ALTER TABLE [dbo].[TableSet]
ADD CONSTRAINT [PK_TableSet]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
-- Creating primary key on [Id] in table 'ItemSet'
ALTER TABLE [dbo].[ItemSet]
ADD CONSTRAINT [PK_ItemSet]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
-- Creating primary key on [Id] in table 'OrderSet'
ALTER TABLE [dbo].[OrderSet]
ADD CONSTRAINT [PK_OrderSet]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
-- Creating primary key on [Id] in table 'MenuSet'
ALTER TABLE [dbo].[MenuSet]
ADD CONSTRAINT [PK_MenuSet]
PRIMARY KEY CLUSTERED ([Id] ASC);
GO
-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------
-- Creating foreign key on [Order_Id] in table 'TableSet'
ALTER TABLE [dbo].[TableSet]
ADD CONSTRAINT [FK_OrderTable]
FOREIGN KEY ([Order_Id])
REFERENCES [dbo].[OrderSet]
([Id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
GO
-- Creating non-clustered index for FOREIGN KEY 'FK_OrderTable'
CREATE INDEX [IX_FK_OrderTable]
ON [dbo].[TableSet]
([Order_Id]);
GO
-- Creating foreign key on [Order_Id] in table 'ItemSet'
ALTER TABLE [dbo].[ItemSet]
ADD CONSTRAINT [FK_OrderItem]
FOREIGN KEY ([Order_Id])
REFERENCES [dbo].[OrderSet]
([Id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
GO
-- Creating non-clustered index for FOREIGN KEY 'FK_OrderItem'
CREATE INDEX [IX_FK_OrderItem]
ON [dbo].[ItemSet]
([Order_Id]);
GO
-- Creating foreign key on [Menu_Id] in table 'ItemSet'
ALTER TABLE [dbo].[ItemSet]
ADD CONSTRAINT [FK_MenuItem]
FOREIGN KEY ([Menu_Id])
REFERENCES [dbo].[MenuSet]
([Id])
ON DELETE NO ACTION ON UPDATE NO ACTION;
GO
-- Creating non-clustered index for FOREIGN KEY 'FK_MenuItem'
CREATE INDEX [IX_FK_MenuItem]
ON [dbo].[ItemSet]
([Menu_Id]);
GO
-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------