-
Notifications
You must be signed in to change notification settings - Fork 1
/
scr.sql
68 lines (57 loc) · 1.2 KB
/
scr.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
/*
Created 1/3/2021
Modified 1/3/2021
Project
Model
Company
Author
Version
Database MS SQL 2005
*/
go
create database notebook
go
use notebook
go
go
Create table [NoteDB]
(
[No] Integer NOT NULL identity(1, 1),
[Title] Nvarchar(200) NOT NULL,
[Date] Smalldatetime NULL,
[Desciption] Nvarchar(4000) NULL,
Primary Key ([Title])
)
go
go
Create table [LoginDB]
(
[No] Integer NOT NULL identity(1, 1) ,
[Username] Nvarchar(200) NOT NULL,
[Password] Varchar(100) NULL,
Primary Key ([Username])
)
go
go
Create table [Note]
(
[No] Integer NOT NULL,
[Title] Nvarchar(200) NOT NULL,
[Username] Nvarchar(200) NOT NULL,
Primary Key ([Username], [Title])
)
go
go
Alter table [Note] add foreign key([No]) references [NoteDB]([No]) on update cascade on delete cascade
go
Alter table [Note] add foreign key([Username]) references [LoginDB] ([Username]) on update cascade on delete cascade
go
Alter table [Note] add foreign key([Title]) references [NoteDB] ([Title]) on update cascade on delete cascade
go
Drop table [Note]
Drop table [NoteDB]
Drop table [LoginDB]
Set quoted_identifier on
go
Set quoted_identifier off
go