Professional Documents
Culture Documents
LAB1 Manual
LAB1 Manual
LAB1 Manual
Table of Contents
Version History..................................................................................................................................................g
Title..........................................................................................................................................................g
Created By...............................................................................................................................................g
Date of Creation......................................................................................................................................g
Maintained By.........................................................................................................................................g
Version No...............................................................................................................................................g
Changes Made.........................................................................................................................................g
Updated By..............................................................................................................................................g
Updating..................................................................................................................................................g
Date.........................................................................................................................................................g
Status.......................................................................................................................................................g
Lab Rubrics........................................................................................................................................................h
Foreword.............................................................................................................................................................j
Database Lab Objective............................................................................................................................j
Course Outcomes.....................................................................................................................................j
Pre-Lab:....................................................................................................................................................j
In-Lab:.......................................................................................................................................................j
Post Lab:...................................................................................................................................................j
Lab Policy..........................................................................................................................................................k
Lab Reports..............................................................................................................................................k
Report Format.........................................................................................................................................k
A title page..............................................................................................................................................k
Practical 1: Basic database concepts & database approach vs file-based system..............................................1
Objective.................................................................................................................................................1
Learning Outcomes.................................................................................................................................1
Activity Time Boxing................................................................................................................................1
Tools and Reading Resources..................................................................................................................1
Theoretical Explanation...........................................................................................................................2
Microsoft Access.....................................................................................................................................2
Required Steps to create and mange DB:................................................................................................2
In Lab Tasks.............................................................................................................................................4
Post Lab Tasks.........................................................................................................................................5
Task 1......................................................................................................................................................5
Task 1....................................................................................................................................................16
Post Lab Tasks.......................................................................................................................................16
Task 1....................................................................................................................................................16
Practical 6: Relational algebra.........................................................................................................................17
Objective...............................................................................................................................................17
Introduction..........................................................................................................................................17
Relational Algebra.................................................................................................................................17
Basic SQL Relational Algebra Operations...............................................................................................17
SELECT (σ)..............................................................................................................................................17
Output -.................................................................................................................................................18
rejection(π)............................................................................................................................................18
Union operation (υ)...............................................................................................................................18
Example.................................................................................................................................................19
Set Difference (-)...................................................................................................................................19
Example.................................................................................................................................................20
Example:................................................................................................................................................21
In Lab Tasks...........................................................................................................................................21
Task 1....................................................................................................................................................21
Post Lab Tasks.......................................................................................................................................21
Task 1....................................................................................................................................................21
Practical 7: Joins and sub queries in SQL.......................................................................................................22
Objective...............................................................................................................................................22
Introduction..........................................................................................................................................22
Joins.......................................................................................................................................................22
Sub query..............................................................................................................................................22
Advantages of Joins...............................................................................................................................22
Advantages of Sub query.......................................................................................................................22
SQL left join keyword.............................................................................................................................23
SQL right join keyword..........................................................................................................................23
In Lab Tasks...........................................................................................................................................23
Tasks 1...................................................................................................................................................23
Post Lab Tasks.......................................................................................................................................24
Tasks 1...................................................................................................................................................24
Practical 8: Grouping and aggregation in SQL................................................................................................25
Objective...............................................................................................................................................25
Introduction..........................................................................................................................................25
SQL GROUPING......................................................................................................................................25
Important Points...................................................................................................................................25
Syntax....................................................................................................................................................25
SQL Aggregation....................................................................................................................................25
In Lab Tasks...........................................................................................................................................25
Task 1....................................................................................................................................................25
Post Lab Tasks.......................................................................................................................................25
Task 1....................................................................................................................................................25
Practical 9: Functional dependencies...............................................................................................................26
Objective...............................................................................................................................................26
Introduction Functional Dependency....................................................................................................26
Example:................................................................................................................................................26
Rules of Functional Dependencies.........................................................................................................26
Types of Functional Dependencies in DBMS.........................................................................................26
Dependencies in DBMS.........................................................................................................................26
Multivalued Dependency in DBMS........................................................................................................27
Example:................................................................................................................................................27
Trivial Functional Dependency in DBMS................................................................................................27
Example.................................................................................................................................................27
Example.................................................................................................................................................28
Transitive Dependency in DBM.............................................................................................................28
Example.................................................................................................................................................28
Advantages of Functional Dependency.................................................................................................29
In Lab Tasks...........................................................................................................................................29
Task 1....................................................................................................................................................29
Post Lab Tasks.......................................................................................................................................29
Task 1....................................................................................................................................................29
Practical 10: Normalization.............................................................................................................................30
Objective...............................................................................................................................................30
Introduction..........................................................................................................................................30
Students................................................................................................................................................31
Faculty...................................................................................................................................................31
In Lab Tasks...........................................................................................................................................32
Task 1....................................................................................................................................................32
Department of Computer Science
Database Systems Lab Manual
e
Task 1....................................................................................................................................................38
Post Lab Tasks.......................................................................................................................................38
Task 1....................................................................................................................................................38
Practical 14: Advanced Data Modelling (OEL-3)...........................................................................................39
Objective...............................................................................................................................................39
Introduction..........................................................................................................................................39
In Lab Tasks...........................................................................................................................................39
Task 1....................................................................................................................................................39
Practical 15: Advanced SQL...........................................................................................................................40
Objective...............................................................................................................................................40
Introduction..........................................................................................................................................40
SQL Server Views...................................................................................................................................40
SQL Server Indexes................................................................................................................................40
SQL Server Stored Procedures...............................................................................................................40
SQL Server User-defined Functions.......................................................................................................40
SQL Server Triggers................................................................................................................................40
Practical 16: NoSQL Systems.........................................................................................................................42
Objective...............................................................................................................................................42
Introduction..........................................................................................................................................42
What is NoSQL?.....................................................................................................................................42
In Lab Task.............................................................................................................................................43
Post Lab Task.........................................................................................................................................43
Version History
Updating
Version No. Changes Made Updated By Status
Date
Provision of
Practicals Lecturer Saima Yasmeen
15-04-2021 ---
v-1.1 Practicals’ Lab Engineer Tabinda NAsir
Additions
Lab Rubrics
All lab reports shall be marked on following Rubrics, the indicated percentage will be out of the report’s marks, for example, if a report is of 10
marks, then specifications shall carry 3.2, originality shall carry 2.8 and object-oriented design shall carry 4 marks.
I. The program is The program The program works The program The program is well-tested for
Specifications producing produces correct and produces the works and meets all valid and in-valid test
32% incorrect results results but does not correct all of the scenarios
display them Results and displays specifications.
correctly. them correctly. It
also meets most of
the other
specifications.
II. The code logic is Code logic is Code logic is self- Code logic is Code logic is completely
Code completely partially copied written with few completely self- self-written and meets all
Originality 28% forged/outputs are and reference of flow written with few requirements
created instead of source is discrepancies errors
produced demonstrated
III. The student is unable to The student The student The student The student adequately
Database demonstrate any database demonstrates adequately adequately demonstrates the concepts of
Design 40% concepts or knowledge. partial knowledge demonstrates the demonstrates the database design, relational
and concepts of concepts of concepts of data model, SQL, joins,
database design. database design, database design, And/or normalization.
relational data relational data Applies advanced knowledge
model, SQL, model, SQL, of database management
joins, and/or joins, and/or including concurrency tools,
normalization. normalization. backup, and/or recovery. The
Department of Computer Science Database Systems Lab Manual
i
Foreword
Database Lab Objective
The major objective of this lab is to provide a strong foundation about database concepts,
technology used for databases and help students to develop the skill of using and creating well-
informed database applications. It enables them to gain knowledge in lab applications of databases.
This lab will help them to familiarize the participant with the nuances of database environments
towards an information-oriented data-processing oriented framework, to give a good formal
foundation on the relational model of data, to present SQL and procedural interfaces to SQL
comprehensively
Course Outcomes
At the end of this lab session, the student will be able to solve real world problems using database
concepts and technology. They will have lab knowledge on the applications of databases.
The lab manual is organized in such a way that the students can directly use it in the laboratory.
Each laboratory exercise comprises of
1. Statement of the problem
2. Solution
3. Results
4. Conclusion
Students must follow this sequence to conduct any database experiment in the lab and write
your report accordingly. The lab is divided into 3 stages. Each stage exemplifies various
concepts. At each stage there are database examples that can be an example of how your
database should look like.
Pre-Lab: At this stage student will come with a proposed solution of the
problem given. When the Lab starts after lab demonstration the problem task
of each individual student will be assessed
In-Lab: At this stage student will go through multiple scenarios and practice their subject
knowledge in it. Group practice is integrated at this stage where student in group of two
perform lab tasks on respective software/tools.
Post Lab: After Lab is completed at this level student will perform given problems at home to
further strengthen their concepts and impart their creative skills.
Lab Policy
Students will be formed into groups / syndicates of two or three on the first lab
day. This pair programming approach may vary depending upon the
experiment nature. However, once a student has signed up with a group in term
project, he may not change groups without prior approval of the instructor.
Lab Reports
Students will perform the Experiment/Lab in group (optional), and turn in
individual laboratory reports on the assigned date of deadline mentioned at the
beginning of each lab experiment detailed document. Your report should be
self-contained, i.e. a computer scientist should be able to perform the
experiment and duplicate your results by reading your report. DO NOT
"adjust" your data to make them fit what you believe to be an acceptable value.
Plagiarism is strictly forbidden in individual reports. Those Students who
found in such activities will be awarded no credits plus re-submission will not
be entertained. For each Lab Task maintain screenshots of results along with
all the program files as a record in a separate lab folder with name of student id
or group id. Task Screenshots should be shown along with program source
code as evidence of task implementation. In order to achieve the expected
results do not “adjust” your actual results instead explain the discrepancies.
Report Format
A report should include the following order.
A title page, which includes the following information, in given format:
Subject/Course Name
Database Systems Lab
Depar
Registration Number/Name Semester/Section
tment
Comp
uter
Scien
ce
Instructor’s
Date Instructor’s Name
Signature
Data is a collection of raw facts and figures processed to obtain useful information to assist
an organization in making decisions. Database is an organized collection of related data. In
order to manage the databases, DBMS offers sets of program and tools
Learning Outcomes
After performing this lab student should be able to
o Install required software
o Explore MS Access Interface
o Explore MS Access Fundamental Objects Like Tables, Forms, Query
o Explore Object Table and its views in MS Access
o Explore Different datatypes in MS Access
1 Concept Deliverance 30
Exploring MS Access Interface
Creating table and Entering data
2 10
Exploring and applying various
datatypes
3 Evaluation/Marking 60
Total Time: 100
Theoretical Explanation
Microsoft Access
Microsoft Access is a database management tool that is part of the Microsoft Office suite. It's
designed to help users store, organize, manage, and retrieve information easily. Here’s a
simple breakdown of what it does:
Database Creation: You can create a database from scratch or use templates. A
database is like a digital filing cabinet where you store data in an organized manner.
Tables for Data Storage: Inside the database, you use tables to store your data. Think
of tables like sheets in a spreadsheet, each with rows and columns. Each row
represents a record, and each column represents a field (a specific piece of data like a
name or a date).
Creating a new database in Microsoft Access is a straightforward process. Here are the steps
to create a new database from scratch:
1. Open Microsoft Access: Start by opening Microsoft Access. If you're using
Windows, you can find it by searching for "Access" in the start menu.
2. Choose to Create a New Database:
On the Access startup screen, you'll see options to open an existing database
or to create a new one. Click on "Blank database" to start a new project from
scratch.
database.
Choose where you want to save your database on your computer by clicking
the folder icon next to the file name field to browse your computer's
directories. Select a location and then click "Create."
4. Access Interface:
Once you've created your database, Access will open to a new, blank table in
Datasheet View. This is where you can start entering data directly.
In Design View, you can define the structure of your table: name your
fields (columns), specify the type of data each field will hold (e.g., Text,
Number, Date/Time), and set a primary key (a unique identifier for each
record in your table).
The data type determines the kind of the values that users can store in
any given field.
Each field can store data consisting of only a single data type.
In Lab Tasks
3. Add a new field named EmailAddress. Set its Data Type to “Short Text” and
specify a field size of 255 characters.
4. Add another field named CreditsEarned. Set its Data Type to “Number” and
under Field Size, select “Integer”.
5. For each field, describe in a brief document why the chosen data type is
appropriate for the content it will hold.
Task 1