Skip to content

Commit

Permalink
Adicionado scripts do mao na massa
Browse files Browse the repository at this point in the history
  • Loading branch information
andrebaltieri committed Apr 14, 2021
1 parent 439025f commit 47da6b1
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 0 deletions.
26 changes: 26 additions & 0 deletions insere_alunos_cursos.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
SELECT * FROM [Course]
SELECT * FROM [Student]
SELECT * FROM [StudentCourse]

INSERT INTO
[Student]
VALUES (
'79b82071-80a8-4e78-a79c-92c8cd1fd052',
'André Baltieri',
'[email protected]',
'12345678901',
'12345678',
NULL,
GETDATE()
)

INSERT INTO
[StudentCourse]
VALUES (
'5f5a33f8-4ff3-7e10-cc6e-3fa000000000',
'79b82071-80a8-4e78-a79c-92c8cd1fd052',
50,
0,
'2020-01-13 12:35:54',
GETDATE()
)
22 changes: 22 additions & 0 deletions insert_into_studen_courses.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
INSERT INTO
[Student]
VALUES (
'c55390d4-71dd-4f3c-b978-d1582f51a327',
'André Baltieri',
'[email protected]',
'12345678901',
'11999999999',
NULL,
GETDATE()
)

INSERT INTO
[StudentCourse]
VALUES (
'5d8cf396-e717-9a02-2443-021b00000000',
'c55390d4-71dd-4f3c-b978-d1582f51a327',
50,
0,
'2021-01-15 12:35:54',
GETDATE()
)
15 changes: 15 additions & 0 deletions spDeleteStudent.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE OR ALTER PROCEDURE spDeleteStudent (
@StudentId UNIQUEIDENTIFIER
)
AS
BEGIN TRANSACTION
DELETE FROM
[StudentCourse]
WHERE
[StudentId] = @StudentId

DELETE FROM
[Student]
WHERE
[Id] = @StudentId
COMMIT
19 changes: 19 additions & 0 deletions spStudentProgress.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE OR ALTER PROCEDURE spStudentProgress (
@StudentId UNIQUEIDENTIFIER
)
AS
SELECT
[Student].[Name] AS [Student],
[Course].[Title] AS [Course],
[StudentCourse].[Progress],
[StudentCourse].[LastUpdateDate]
FROM
[StudentCourse]
INNER JOIN [Student] ON [StudentCourse].[StudentId] = [Student].[Id]
INNER JOIN [Course] ON [StudentCourse].[CourseId] = [Course].[Id]
WHERE
[StudentCourse].[StudentId] = @StudentId
AND [StudentCourse].[Progress] < 100
AND [StudentCourse].[Progress] > 0
ORDER BY
[StudentCourse].[LastUpdateDate] DESC
13 changes: 13 additions & 0 deletions vwCareers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE OR ALTER VIEW vwCareers AS
SELECT
[Career].[Id],
[Career].[Title],
[Career].[Url],
COUNT([Id]) AS [Courses]
FROM
[Career]
INNER JOIN [CareerItem] ON [CareerItem].[CareerId] = [Career].[Id]
GROUP BY
[Career].[Id],
[Career].[Title],
[Career].[Url]
16 changes: 16 additions & 0 deletions vwCourses.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CREATE OR ALTER VIEW vwCourses AS
SELECT
[Course].[Id],
[Course].[Tag],
[Course].[Title],
[Course].[Url],
[Course].[Summary],
[Course].[CreateDate],
[Category].[Title] AS [Category],
[Author].[Name] AS [Author]
FROM
[Course]
INNER JOIN [Category] ON [Course].[CategoryId] = [Category].[Id]
INNER JOIN [Author] ON [Course].[AuthorId] = [Author].[Id]
WHERE
[Active] = 1

0 comments on commit 47da6b1

Please sign in to comment.