forked from balta-io/2805
-
Notifications
You must be signed in to change notification settings - Fork 0
/
001.sql
50 lines (40 loc) · 1.13 KB
/
001.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
USE [Curso]
DROP TABLE [Aluno]
CREATE TABLE [Aluno] (
[Id] INT NOT NULL,
[Nome] NVARCHAR(80) NOT NULL,
[Email] NVARCHAR(180) NOT NULL,
[Nascimento] DATETIME NULL,
[Active] BIT NOT NULL DEFAULT(0),
CONSTRAINT [PK_Aluno] PRIMARY KEY([Id]),
CONSTRAINT [UQ_Aluno_Email] UNIQUE([Email]),
)
GO
CREATE INDEX [IX_Aluno_Email] ON [Aluno]([Email])
DROP INDEX [IX_Aluno_Email] ON [Aluno]
SELECT NEWID()
DROP TABLE [Curso]
CREATE TABLE [Curso] (
[Id] INT NOT NULL IDENTITY(1, 1),
[Nome] NVARCHAR(80) NOT NULL,
[CategoriaId] INT NOT NULL,
CONSTRAINT [PK_Curso] PRIMARY KEY([Id]),
CONSTRAINT [FK_Curso_Categoria] FOREIGN KEY([CategoriaId])
REFERENCES [Categoria]([Id])
)
GO
CREATE TABLE [Categoria] (
[Id] INT NOT NULL,
[Nome] NVARCHAR(80) NOT NULL,
CONSTRAINT [PK_Categoria] PRIMARY KEY([Id])
)
GO
DROP TABLE [ProgressoCurso]
CREATE TABLE [ProgressoCurso] (
[AlunoId] INT NOT NULL,
[CursoId] INT NOT NULL,
[Progresso] INT NOT NULL,
[UltimaAtualizacao] DATETIME NOT NULL DEFAULT(GETDATE()),
CONSTRAINT PK_ProgressoCurso PRIMARY KEY([AlunoId], [CursoId]),
)
GO