From 439025f4f492d91f31ed87b360a12c3cbd8a1e55 Mon Sep 17 00:00:00 2001 From: Andre Baltieri Date: Tue, 13 Apr 2021 11:44:24 -0300 Subject: [PATCH] Adicionado scripts e base demo --- 001.sql | 50 +++++++++++++++++ balta-database.sql | 110 +++++++++++++++++++++++++++++++++++++ balta.zip | Bin 0 -> 16889 bytes create_database_cursos.sql | 23 ++++++++ drop_database.sql | 10 ++++ inserts.sql | 8 +++ select.sql | 9 +++ spListCourse.sql | 8 +++ 8 files changed, 218 insertions(+) create mode 100644 001.sql create mode 100644 balta-database.sql create mode 100644 balta.zip create mode 100644 create_database_cursos.sql create mode 100644 drop_database.sql create mode 100644 inserts.sql create mode 100644 select.sql create mode 100644 spListCourse.sql diff --git a/001.sql b/001.sql new file mode 100644 index 0000000..42dd64f --- /dev/null +++ b/001.sql @@ -0,0 +1,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 \ No newline at end of file diff --git a/balta-database.sql b/balta-database.sql new file mode 100644 index 0000000..fe88861 --- /dev/null +++ b/balta-database.sql @@ -0,0 +1,110 @@ +CREATE DATABASE [balta] +GO + +USE [balta] +GO + +CREATE TABLE [Student] +( + [Id] uniqueidentifier NOT NULL, + [Name] NVARCHAR(120) NOT NULL, + [Email] NVARCHAR(180) NOT NULL, + [Document] NVARCHAR(20) NULL, + [Phone] NVARCHAR(20) NULL, + [Birthdate] DATETIME NULL, + [CreateDate] DATETIME NOT NULL DEFAULT(GETDATE()), + CONSTRAINT [PK_Student] PRIMARY KEY ([Id]) +); +GO + +CREATE TABLE [Author] +( + [Id] uniqueidentifier NOT NULL, + [Name] NVARCHAR(80) NOT NULL, + [Title] NVARCHAR(80) NOT NULL, + [Image] NVARCHAR(1024) NOT NULL, + [Bio] NVARCHAR(2000) NOT NULL, + [Url] nvarchar(450) NULL, + [Email] NVARCHAR(160) NOT NULL, + [Type] TINYINT NOT NULL, -- 0 a 255 + CONSTRAINT [PK_Author] PRIMARY KEY ([Id]) +); +GO + +CREATE TABLE [Career] +( + [Id] uniqueidentifier NOT NULL, + [Title] NVARCHAR(160) NOT NULL, + [Summary] NVARCHAR(2000) NOT NULL, + [Url] NVARCHAR(1024) NOT NULL, + [DurationInMinutes] INT NOT NULL, + [Active] BIT NOT NULL, + [Featured] BIT NOT NULL, + [Tags] NVARCHAR(160) NOT NULL, + CONSTRAINT [PK_Career] PRIMARY KEY ([Id]) +); +GO + +CREATE TABLE [Category] +( + [Id] uniqueidentifier NOT NULL, + [Title] NVARCHAR(160) NOT NULL, + [Url] NVARCHAR(1024) NOT NULL, + [Summary] NVARCHAR(2000) NOT NULL, + [Order] int NOT NULL, + [Description] TEXT NOT NULL, + [Featured] BIT NOT NULL, + CONSTRAINT [PK_Category] PRIMARY KEY ([Id]) +); +GO + +CREATE TABLE [Course] +( + [Id] uniqueidentifier NOT NULL, + [Tag] NVARCHAR(20) NOT NULL, + [Title] NVARCHAR(160) NOT NULL, + [Summary] NVARCHAR(2000) NOT NULL, + [Url] NVARCHAR(1024) NOT NULL, + [Level] TINYINT NOT NULL, + [DurationInMinutes] INT NOT NULL, + [CreateDate] DATETIME NOT NULL, + [LastUpdateDate] DATETIME NOT NULL, + [Active] BIT NOT NULL, + [Free] BIT NOT NULL, + [Featured] BIT NOT NULL, + [AuthorId] uniqueidentifier NOT NULL, + [CategoryId] uniqueidentifier NOT NULL, + [Tags] NVARCHAR(160) NOT NULL, + CONSTRAINT [PK_Course] PRIMARY KEY ([Id]), + CONSTRAINT [FK_Course_Author_AuthorId] FOREIGN KEY ([AuthorId]) REFERENCES [Author] ([Id]), + CONSTRAINT [FK_Course_Category_CategoryId] FOREIGN KEY ([CategoryId]) REFERENCES [Category] ([Id]) +); +GO + +CREATE TABLE [CareerItem] +( + [CareerId] uniqueidentifier NOT NULL, + [CourseId] uniqueidentifier NOT NULL, + [Title] NVARCHAR(160) NOT NULL, + [Description] TEXT NOT NULL, + [Order] TINYINT NOT NULL, + + CONSTRAINT [PK_CareerItem] PRIMARY KEY ([CourseId], [CareerId]), + CONSTRAINT [FK_CareerItem_Career_CareerId] FOREIGN KEY ([CareerId]) REFERENCES [Career] ([Id]), + CONSTRAINT [FK_CareerItem_Course_CourseId] FOREIGN KEY ([CourseId]) REFERENCES [Course] ([Id]) +); +GO + +CREATE TABLE [StudentCourse] +( + [CourseId] uniqueidentifier NOT NULL, + [StudentId] uniqueidentifier NOT NULL, + [Progress] TINYINT NOT NULL, + [Favorite] BIT NOT NULL, + [StartDate] DATETIME NOT NULL, + [LastUpdateDate] DATETIME NULL DEFAULT(GETDATE()), + CONSTRAINT [PK_StudentCourse] PRIMARY KEY ([CourseId], [StudentId]), + CONSTRAINT [FK_StudentCourse_Course_CourseId] FOREIGN KEY ([CourseId]) REFERENCES [Course] ([Id]), + CONSTRAINT [FK_StudentCourse_Student_StudentId] FOREIGN KEY ([StudentId]) REFERENCES [Student] ([Id]) +); +GO \ No newline at end of file diff --git a/balta.zip b/balta.zip new file mode 100644 index 0000000000000000000000000000000000000000..18f8cc48b0bd533a7396d21ebd5eeeeb105e6551 GIT binary patch literal 16889 zcmV(pK=8j%O9KQH0000807G4kQab3tL4QF20BBAC01N;C0AgWmbYU)HVPkM%W39Xe zbR0>tE-YEhY%#MeXfZQ0Gee7+nJloF*j%va;s^eXE6 zyaQWRLbx`9I-1NK6?hhx&|$z>H4C)5xg1ccwTbQ`0vnfZ)&PDlh-tURR3}g<%K)b2 zt-O^kXD?aIcCw35w6J?d%GE$ts8}oNitC_zKdToSagnD3Nq-0ziuFBH699!EF%U|V_yCd4&m+_gO4W0RNtPXCA`0dl zcD8RcELF|`|MN`)uJ=hWojyff(KcMl?JR6@jJ>3A4#VKhawvgH?Gsp7+3$7Zz@JmX z`D1MtgMHc*ZF|X;l=;9wL!1j|%c(1?rjJv?lkSbam@2n>B3U$Tc7_Cd7->k|jOF1q zR8g!!@EaLu$2QTLD$Rw6n;f)Phqq*#h8P`rjy8X(GT<`V08BV26eKs83m2D`@kK8<6wqTpMN6~2EBs2-CkWnK zZl?!hC-{NO_DE+BQD!7MwOX4yW0dEacX;rsB=^@+5qaOc8a}DMY4VE5 z(R%Ql@NCekqJ}qD7m3|Cjjn=VUljY-*4szcsh7mU7#*Sw(~3Z*9-)$=l0KHbenaLH z7CV-x)Z&jzHo;8ZMxBW?C?L4`1hjLC!xQUd<_(V{ow^$;Rk@Rs`I;0^lZBG65Yf9^ zAlo8g4^BfMhah&l<^1W>i;4(m^yJs=rcWbo>^0pt0qb;>R0$+&b&j;FZly>R>>-a1(#Qt7U8)voTgFm1wNc5B z6iFzD6Re%aF z7>x;-zE2(|%lb->Ofp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v=XvofKV#oqyGx`66?=Of0aGEfh7@BgL{QS?t z&cXceG5)>6<M{v zHDNYkVlg#j|LG(wtVS&VCAPmN%+Lg2Y{JIE&dA2h%)-h3FBSP;qWfnzF*N?^^G3#o z#!Q?nECAF0O>}?alZHlY>;OgpqY2wjX&nF2cK;9K+MggZ1hN4Qjg3v%4FNxWlJmbs z_7_AM|HSkYn<2|@F2Zd3mvH?*j%$B1m;$qu^u5U-b4G_jSWK<2-g3r2(VBWk8R6NT ziXYNjHcLxy+GHSE_{Ue~u)L7$KKrzwvMbItS_>2u_RD728*An!T1TfZSiAXO{`aR# ze%}sxwmvE6%(NcYd5IfdiGl?z92&GfkP_xa2H-G6V+X?aoq?tOg@ zYe{+9kK37T_PHO;&;D81x^VB_t*syLUpbhN{)VSyS#ePri`1<@+I;($PWj)~x_a$N z{Sz<#v5Wqd4?4{M|GS#xzh#T(yD`+Z^L<+Xz4({%-}>Fwe{a3HepkG1xxtJ2Tip+@ zAKU+~^n-Qgfj>{@^4F#Q%8vc}UWMcP{OOA&{+m9I=e}64&i!M5%(Q>nm*cx<)vLQ7 z*&p-h50G=ZrCwcp$^IA<5XU>Ye!1n7{V^K9ft>qYKjt#X|GQlEX@BDH*N48mXYu<# z|HeOQ(LcM4{#ff?{9j%F*W9N**5L2l4GjNp#{X{>`uFDIh4&(-{`T{C)#ZPG9(?=$ z%ij0=!gu4P|J|DW-*1vo{jK%d9?lN`$|PStSLcvnNs0NiJ?uYwfHxzP2m|h;8i1!Y d0D%ISL_N46z?+o~B+LkeRzP|s@PG#f1^}UJCg=bF literal 0 HcmV?d00001 diff --git a/create_database_cursos.sql b/create_database_cursos.sql new file mode 100644 index 0000000..a895803 --- /dev/null +++ b/create_database_cursos.sql @@ -0,0 +1,23 @@ +CREATE DATABASE [Cursos] +GO + +USE [Cursos] + +CREATE TABLE [Categoria] ( + [Id] INT NOT NULL IDENTITY(1, 1), + [Nome] NVARCHAR(80) NOT NULL, + + CONSTRAINT [PK_Categoria] PRIMARY KEY([Id]) +) +GO + +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 \ No newline at end of file diff --git a/drop_database.sql b/drop_database.sql new file mode 100644 index 0000000..511f9b4 --- /dev/null +++ b/drop_database.sql @@ -0,0 +1,10 @@ +USE [master]; + +DECLARE @kill varchar(8000) = ''; +SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), session_id) + ';' +FROM sys.dm_exec_sessions +WHERE database_id = db_id('Curso') + +EXEC(@kill); + +DROP DATABASE [Curso] \ No newline at end of file diff --git a/inserts.sql b/inserts.sql new file mode 100644 index 0000000..cbf26ee --- /dev/null +++ b/inserts.sql @@ -0,0 +1,8 @@ +INSERT INTO [Categoria]([Nome]) VALUES('Backend') +INSERT INTO [Categoria]([Nome]) VALUES('Frontend') +INSERT INTO [Categoria]([Nome]) VALUES('Mobile') + +INSERT INTO [Curso]([Nome], [CategoriaId]) VALUES('Fundamentos de C#', 1) +INSERT INTO [Curso]([Nome], [CategoriaId]) VALUES('Fundamentos OOP', 1) +INSERT INTO [Curso]([Nome], [CategoriaId]) VALUES('Angular', 2) +INSERT INTO [Curso]([Nome], [CategoriaId]) VALUES('Flutter', 3) \ No newline at end of file diff --git a/select.sql b/select.sql new file mode 100644 index 0000000..628613e --- /dev/null +++ b/select.sql @@ -0,0 +1,9 @@ +SELECT TOP 100 + [Id], [Nome], [CategoriaId] +FROM + [Curso] +-- WHERE +-- [CategoriaId] = 1 +ORDER BY + [Nome] DESC + \ No newline at end of file diff --git a/spListCourse.sql b/spListCourse.sql new file mode 100644 index 0000000..0497dba --- /dev/null +++ b/spListCourse.sql @@ -0,0 +1,8 @@ +CREATE OR ALTER PROCEDURE [spListCourse] + @Category NVARCHAR(60), + @Par2 NVARCHAR(60) +AS + DECLARE @CategoryId INT + SET @CategoryId = (SELECT TOP 1 [Id] FROM [Categoria] WHERE [Nome] = @Category) + + SELECT * FROM [Curso] WHERE [CategoriaId] = @CategoryId