100% found this document useful (1 vote)
180 views3 pages

Quiz2 2021 Cmuis401sc

This document contains instructions for a quiz on database concepts. It includes questions about creating stored procedures to retrieve student details based on an ID number, creating triggers to check that faculty IDs exist when inserting class data, creating indexes to optimize queries counting total students enrolled by class name, and database security tasks like creating a login, user, granting and revoking privileges. The student is asked to write SQL commands to complete the tasks.

Uploaded by

Lê Duẩn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
180 views3 pages

Quiz2 2021 Cmuis401sc

This document contains instructions for a quiz on database concepts. It includes questions about creating stored procedures to retrieve student details based on an ID number, creating triggers to check that faculty IDs exist when inserting class data, creating indexes to optimize queries counting total students enrolled by class name, and database security tasks like creating a login, user, granting and revoking privileges. The student is asked to write SQL commands to complete the tasks.

Uploaded by

Lê Duẩn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Duy Tan University QUIZ 2 Code:

International School Course: Information Systems Application 01

Programs: CMU Classes: CMU-IS 401-SC

School year :2020 -2021

Duration: 30 minutes

FULL NAME: Mai Le Duan CLASS: CMU-IS 401-SC ID: 24211204940

1. Consider the following schema:

Student(snum, sname, major, level, age)

Class(cname, room, fid)

Enrolled(snum, cname)

Faculty(fid, fname, deptid)

1.1. Create Procedure have function list the details of student when inputing data to the
snum field

GO

CREATE PROC SP_DETAIL_STUDENT

@SNUM CHAR(3)

AS

IF EXISTS(SELECT snum FROM Student WHERE snum = @SNUM)

SELECT *FROM Student

WHERE snum = @SNUM;

ELSE

PRINT N’Snum này không tồn tại’;

EXEC PROC SP_DETAIL_STUDENT ‘S01‘;

No 2 Page 1
1.2. Write trigger: when inserting data to the Class table, then check the existence fid in the
FacultyTable

GO

CREATE TRIGGER TR_CHECK_FID ON Class

FOR INSERT

AS

IF NOT EXISTS(SELECT fid FROM Faculty WHERE fid = (SELECT fid FROM
INSERTED))

RAISERROR(‘%d FID không tồn tại’,0,1,@@ROWCOUNT)

ELSE

RAISERROR(‘%d Dòng này được thêm thành


công’,0,1,@@ROWCOUNT);

1.3. For each of the following reports, indicate any indexes that you feel would help the report
run faster as well as the type of index. Write SQL commands to create indexes for each
attribute you identified

cname Total _of_student

CREATE CLUSTERED INDEX SNUM_INDEX

ON Enrolled(snum);

CREATE CLUSTERED INDEX CNAME_INDEX

ON Enrolled(cname);

2. Database security- (DB_ABC)

2.1. Creates the login ‘MARY’. The user login starts with the password "123," but that
password must be changed after the first login.

CREATE LOGIN MARY WITH PASSWORD = '123' MUST_CHANGE,


CHECK_EXPIRATION = ON;

2.2. Creates a database user for the login created above

No 2 Page 2
CREATE USER MARY FOR LOGIN MARY;

2.3. To grant ALL privilege on the Emp in the schema part 2 the user ‘MARY’

2.4. To Revoke UPDATE, DELETE privilege on the Emp from user ‘MARY’

Instructor, Duy Tan University

M.Sc Nguyen Thi Thanh Tam

No 2 Page 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy