-
Notifications
You must be signed in to change notification settings - Fork 0
/
SGA-Database-Mark3.sql
194 lines (173 loc) · 4.86 KB
/
SGA-Database-Mark3.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
CREATE TABLE [Users] (
User_ID int NOT NULL,
UserName varchar(255) NOT NULL,
UserEmail varchar(255) NOT NULL,
Description varchar(255) NOT NULL,
CONSTRAINT [PK_USERS] PRIMARY KEY CLUSTERED
(
[User_ID] ASC
) WITH (IGNORE_DUP_KEY = OFF)
)
GO
CREATE TABLE [Roles] (
Role_ID int NOT NULL,
RoleName varchar(255) NOT NULL,
CONSTRAINT [PK_ROLES] PRIMARY KEY CLUSTERED
(
[Role_ID] ASC
) WITH (IGNORE_DUP_KEY = OFF)
)
GO
CREATE TABLE [Cross_Users_Roles] (
User_ID int NOT NULL,
Role_ID int NOT NULL
)
GO
CREATE TABLE [Permissions] (
Perm_ID int NOT NULL,
Code_name varchar(255) NOT NULL,
Pretty_name varchar(255) NOT NULL,
Description varchar(255) NOT NULL,
CONSTRAINT [PK_PERMISSIONS] PRIMARY KEY CLUSTERED
(
[Perm_ID] ASC
) WITH (IGNORE_DUP_KEY = OFF)
)
GO
CREATE TABLE [Cross_Role_Perm] (
Role_ID int NOT NULL,
Perm_ID int NOT NULL
)
GO
CREATE TABLE [Prop_Type] (
Prop_ID int NOT NULL,
Bill varchar(1000) NOT NULL,
Resolution varchar(1000) NOT NULL,
Status int NOT NULL,
CONSTRAINT [PK_PROP_TYPE] PRIMARY KEY CLUSTERED
(
[Prop_ID] ASC
) WITH (IGNORE_DUP_KEY = OFF)
)
GO
CREATE TABLE [Attendance] (
User_ID int NOT NULL,
Meeting_ID int NOT NULL,
EntryTime datetime NOT NULL
)
GO
CREATE TABLE [Announcements] (
User_ID int NOT NULL,
Title varchar(255) NOT NULL,
subject varchar(255) NOT NULL,
body varchar(255) NOT NULL,
Date datetime NOT NULL,
CONSTRAINT [PK_ANNOUNCEMENTS] PRIMARY KEY CLUSTERED
(
[User_ID] ASC
) WITH (IGNORE_DUP_KEY = OFF)
)
GO
CREATE TABLE [Meeting] (
Meeting_ID int NOT NULL,
MeetingTime datetime NOT NULL,
Lattitude decimal NOT NULL,
Longitude decimal NOT NULL,
MeetingNum int NOT NULL,
Minutes text NOT NULL,
CONSTRAINT [PK_MEETING] PRIMARY KEY CLUSTERED
(
[Meeting_ID] ASC
) WITH (IGNORE_DUP_KEY = OFF)
)
GO
CREATE TABLE [Submitter] (
Prop_ID int NOT NULL,
User_ID int NOT NULL,
Type int NOT NULL,
CONSTRAINT [PK_SUBMITTER] PRIMARY KEY CLUSTERED
(
[Prop_ID] ASC
) WITH (IGNORE_DUP_KEY = OFF)
)
GO
CREATE TABLE [Approver] (
Prop_ID int NOT NULL,
User_ID int NOT NULL,
Type int NOT NULL,
CONSTRAINT [PK_APPROVER] PRIMARY KEY CLUSTERED
(
[Prop_ID] ASC
) WITH (IGNORE_DUP_KEY = OFF)
)
GO
CREATE TABLE [Voting] (
User_ID int NOT NULL,
VoteChoice int NOT NULL,
VoteDate datetime NOT NULL,
CONSTRAINT [PK_VOTING] PRIMARY KEY CLUSTERED
(
[User_ID] ASC
) WITH (IGNORE_DUP_KEY = OFF)
)
GO
ALTER TABLE [Cross_Users_Roles] WITH CHECK ADD CONSTRAINT [Cross_Users_Roles_fk0] FOREIGN KEY ([User_ID]) REFERENCES [Users]([User_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Cross_Users_Roles] CHECK CONSTRAINT [Cross_Users_Roles_fk0]
GO
ALTER TABLE [Cross_Users_Roles] WITH CHECK ADD CONSTRAINT [Cross_Users_Roles_fk1] FOREIGN KEY ([Role_ID]) REFERENCES [Roles]([Role_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Cross_Users_Roles] CHECK CONSTRAINT [Cross_Users_Roles_fk1]
GO
ALTER TABLE [Cross_Role_Perm] WITH CHECK ADD CONSTRAINT [Cross_Role_Perm_fk0] FOREIGN KEY ([Role_ID]) REFERENCES [Roles]([Role_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Cross_Role_Perm] CHECK CONSTRAINT [Cross_Role_Perm_fk0]
GO
ALTER TABLE [Cross_Role_Perm] WITH CHECK ADD CONSTRAINT [Cross_Role_Perm_fk1] FOREIGN KEY ([Perm_ID]) REFERENCES [Permissions]([Perm_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Cross_Role_Perm] CHECK CONSTRAINT [Cross_Role_Perm_fk1]
GO
ALTER TABLE [Attendance] WITH CHECK ADD CONSTRAINT [Attendance_fk0] FOREIGN KEY ([User_ID]) REFERENCES [Users]([User_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Attendance] CHECK CONSTRAINT [Attendance_fk0]
GO
ALTER TABLE [Attendance] WITH CHECK ADD CONSTRAINT [Attendance_fk1] FOREIGN KEY ([Meeting_ID]) REFERENCES [Meeting]([Meeting_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Attendance] CHECK CONSTRAINT [Attendance_fk1]
GO
ALTER TABLE [Announcements] WITH CHECK ADD CONSTRAINT [Announcements_fk0] FOREIGN KEY ([User_ID]) REFERENCES [Users]([User_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Announcements] CHECK CONSTRAINT [Announcements_fk0]
GO
ALTER TABLE [Submitter] WITH CHECK ADD CONSTRAINT [Submitter_fk0] FOREIGN KEY ([Prop_ID]) REFERENCES [Prop_Type]([Prop_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Submitter] CHECK CONSTRAINT [Submitter_fk0]
GO
ALTER TABLE [Submitter] WITH CHECK ADD CONSTRAINT [Submitter_fk1] FOREIGN KEY ([User_ID]) REFERENCES [Users]([User_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Submitter] CHECK CONSTRAINT [Submitter_fk1]
GO
ALTER TABLE [Approver] WITH CHECK ADD CONSTRAINT [Approver_fk0] FOREIGN KEY ([Prop_ID]) REFERENCES [Prop_Type]([Prop_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Approver] CHECK CONSTRAINT [Approver_fk0]
GO
ALTER TABLE [Approver] WITH CHECK ADD CONSTRAINT [Approver_fk1] FOREIGN KEY ([User_ID]) REFERENCES [Users]([User_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Approver] CHECK CONSTRAINT [Approver_fk1]
GO
ALTER TABLE [Voting] WITH CHECK ADD CONSTRAINT [Voting_fk0] FOREIGN KEY ([User_ID]) REFERENCES [Users]([User_ID])
ON UPDATE CASCADE
GO
ALTER TABLE [Voting] CHECK CONSTRAINT [Voting_fk0]
GO