This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database-init.sql
72 lines (62 loc) · 1.62 KB
/
database-init.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
create table Categories
(
CategoryId uniqueidentifier not null rowguidcol,
Name nvarchar(max) not null
)
go
alter table Categories
add constraint Categories_pk
primary key (CategoryId)
go
create table LinkGroups
(
LinkGroupId uniqueidentifier not null rowguidcol,
Name nvarchar(max) not null,
Description nvarchar(max),
ShortName nvarchar(50) not null,
UserId uniqueidentifier,
Clicked int default 0 not null,
CategoryId uniqueidentifier not null,
CreatedAt datetime not null
)
go
alter table LinkGroups
add constraint LinkGroups_pk
primary key (LinkGroupId)
go
alter table LinkGroups
add constraint LinkGroups_Categories_CategoryId_fk
foreign key (CategoryId) references Categories
go
create table Links
(
LinkId uniqueidentifier not null rowguidcol,
Name nvarchar(max) not null,
Url nvarchar(max) not null,
LinkGroupId uniqueidentifier not null
)
go
alter table Links
add constraint Links_pk
primary key (LinkId)
go
alter table Links
add constraint Links_LinkGroups_LinkGroupId_fk
foreign key (LinkGroupId) references LinkGroups
go
create table Users
(
UserId uniqueidentifier not null rowguidcol,
FullName nvarchar(max),
Email nvarchar(max) not null,
Password nvarchar(max) not null
)
go
alter table Users
add constraint Users_pk
primary key (UserId)
go
alter table LinkGroups
add constraint LinkGroups_Users_UserId_fk
foreign key (UserId) references Users
go