Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Pir Mehr Ali Shah

Arid Agriculture University, Rawalpindi


Office of the controller of Examinations
Final Exam (Theory) / Fall 2020 (Paper Duration 24 hours)
To be filled by Teacher

Course No.: CS-704 Course Title: Database System


Total Marks: 20 Date of Exam: 8-2-2021
Degree: MCS Semester: 2 Section: A
Marks
Q. No. 1 2 3 4 5 6 7 8 9 10 Obtained/
TotalMarks
Marks
Obtaine
d
Total Marks in Words:
Name of the teacher: Saba Un Nisa
Who taught the course: Signature of teacher / Examiner:

To be filled by Student

Registration No.: 20-ARID-417 Name: UMAIR FAZAL

Answer the following questions.

Question No. 1:
Student Table:
Course Table:

Enrollment Table:
Queries

i) select sName from Student INNER join Enrollment on Enrollment.Grade='A' AND


Student.regNo=Enrollment.regNo;

ii) select sName,cName from

Enrollment enr

INNER JOIN Student stu on enr.regNo=stu.regNo

INNER JOIN Course crs on enr.cCode=crs.cCode;


iii) SELECT S.regNo, S.sName, S.sCity, S.sCGPA, S.sAge

FROM Student AS S INNER JOIN Enrollment AS E ON E.regNo = S.regNo

GROUP BY S.regNo, S.sName

HAVING COUNT(*) >= 10 ;

iv) SELECT student.sName FROM student LEFT JOIN enrollment ON student.regNo =


enrollment.regNo WHERE enrollment.regNo IS NULL
v) SELECT student.sName, enrollment.Grade FROM student RIGHT JOIN enrollment ON
student.regNo = enrollment.regNo WHERE student.sName ='Ali' AND enrollment.cCode
='CS101' ;

Question No. 2: Write short answers:


a. Differentiate between high level language and low level language queries.

Answer: The high level language queries runs on top of the machine language and provides high
level of abstraction.

High Level Language example: Sql

The low level language queries are machine friendly. It provides no or less abstraction from the
hardware.

Low Level language example : Relational Algebra

b. Abbreviate the ACID of transaction system.


Answer: The acronym ACID refers to the four main properties of a transaction in the sense of
transaction processing: atomicity, consistency, isolation, and durability. It is a mnemonic device for
learning. Transactions access data using read and write operations.

c. What are the basic operation of the relational algebra?

Answer: Relational algebra is a procedural query language.

It is used for providing a single table as output for performing operations.

It takes relations as input and returns relations as output.

Basic operators such as +,-,* are applied on relations for producing required results.

d. Explain the anomalies in relational database.

Answer: There are different types of anomalies that can occur in relations. They are:

Insertion anomaly: If a tuple is inserted in referencing relation and referencing attribute value is not
present in referenced attribute, it will not allow inserting in referencing relation.

Deletion and Updation anomaly: If a tuple is deleted or updated from referenced relation and the
referenced attribute value is used by referencing an attribute in referencing relation, it will not allow
deleting the tuple from referenced relation.

e. Explain natural join with example.

Answer: A NATURAL JOIN is a JOIN operation that creates an implicit join clause for you based on
the common columns in the two tables being joined. Common columns are columns that have the
same name in both tables.

A NATURAL JOIN can be an INNER join, a LEFT OUTER join, or a RIGHT OUTER join. The default is
INNER join.

Syntax:

TableExpression NATURAL [ { LEFT | RIGHT } [ OUTER ] | INNER ] JOIN


{ TableViewOrFunctionExpression | ( TableExpression ) }

Examples:

SELECT * FROM COUNTRIES NATURAL JOIN CITIES

SELECT * FROM COUNTRIES NATURAL LEFT JOIN CITIES

Question No. 3: Write SQL statements and relation algebra for following:
Answer:

i) Alter Table student ADD (city varchar (255));


ii) SELECT * FROM Student S where s.courseId=(SELECT c.courseId FROM Course c where
c.course_nm="computer");

iii) SELECT course_nm,courseId, duration FROM Course

iv) select name from student where name LIKE 'a%'


v) SELECT student.emailId, student.cellno, course.course_nm FROM student, course WHERE
student.courseId = course.courseId AND course.course_nm = 'mechanical engineering'

Relational Algebra Queries:

1) Alter Table student ADD (city varchar (255));

2) Π student.Enrno, student.name, student.emailId, student.cellno, student.city(σ student.courseId


= course.courseId AND course.course_nm = 'computer'(student) X (course))

3) Π courseId, course_nm, duration (course)

4) Π Enrno, name, courseId, emailId, cellno, city (σ name LIKE'a%'(student))

5) Π student.emailId, student.cellno, course.course_nm (σ student.courseId = course.courseId AND


course.course_nm = 'mechanical engineering (student) X (course))

Question No. 4:
Answer: DBMS (Database Management Systems) refers to the technology approach used to
optimize and handle database data storage and retrieval.

Security of databases requires a number of security controls designed to secure the framework of
database management (DBMS). Protecting the underlying infrastructure that houses the database,
such as the network and servers, safely configuring the DBMS, and accessing the data itself, are the
types of database security measures the company can use.
Protection of databases includes various controls, including device hardening, access, configuration
of DBMS, and monitoring of security. These various security measures assist in monitoring the
circumvention of security protocols.

System hardening and monitoring

Extra access to the DBMS is provided by the underlying architecture. It is important that all devices,
including insider threats, are regularly patched, hardened using established security configuration
norms, and monitored for entry.

DBMS configuration

It is important to properly configure and harden the DBMS to take advantage of security features
and restrict privileged access that can cause the intended security settings to be misconfigured.
Monitoring the configuration of the DBMS and maintaining proper procedures of change control
helps ensure the configuration remains consistent.

Authentication

Database security measures include authentication, the process of checking whether user
credentials match those stored in your database, and allowing access to your files, networks, and
database platforms for authenticated users only.

Access

The successful restriction of access to your data is a primary outcome of database security. Access
controls authenticate legitimate users and programs, restricting the database to what they can
access. Access means designing and granting suitable attributes and responsibilities for users and
restricting administrative rights.

Database auditing

Centralized control of the database is established by tracking (or auditing) activities as part of a
database security protocol. Auditing helps to track, prevent, and decrease the cumulative effect of
your DBMS unauthorized access.

Backups

A data backup makes a copy of your data and stores it on a different device as part of your database
security protocol. This backup enables you to recover missing information that can result from
hardware failures, manipulation of data, fraud, hacking, or natural disasters.

Encryption

Database security may include safe encryption key management, encryption device protection,
secure, off-site encryption backup management, and protocols for access restriction.
Application security

Security framework interventions for databases and applications can help defend against common
known intruder vulnerabilities that can bypass access controls, including injection of SQL.

There are 5 key steps to ensuring database security, according to administrative procedure:

Isolate sensitive databases - Keep an accurate list of all enterprise-wide databases and classify all
confidential information residing on those databases.

Eliminate vulnerabilities- Evaluate, locate and remedy bugs that expose the database on a
continuous basis.

Enforce least privileges- Identify user rights and implement restrictions and privileges for user
access to restrict access to only the minimal data necessary for workers to do their jobs.

Monitor for deviations- Enforce appropriate policies and monitor any vulnerabilities that can not be
patched for any and all behavior that deviates from approved activity.

Respond to suspicious behavior- To mitigate the risk of attack, alert and respond in real time to any
abnormal or suspicious activity.

You might also like