Regular-Lab-Book-Upto 3 RD Experiment
Regular-Lab-Book-Upto 3 RD Experiment
Regular-Lab-Book-Upto 3 RD Experiment
22AD2102R
STUDENT NAME:
22AD2102R` –Database Management Systems
Table of Contents
1. Installation of PostgreSQL Client & Server .................................................................. 2
10. Implementation of Group by & Having Clauses and Set Operations ....................... 82
11. Implementation of Correlated Nested, Views, Indices and DCL Commands .......... 87
Pre-Lab
The Prelab exercise is a homework assignment that links the lecture with the laboratory period -
typically takes 2 hours to complete. The goal is to synthesize the information they learn in lecture with
material from their textbook to produce a working piece of software. Prelab Students attending a two-
hour closed laboratory are expected to make a good-faith effort to complete the Prelab exercise before
coming to the lab. Their work need not be perfect, but their effort must be
real(roughly80percentcorrect).
In-Lab
The In-lab section takes place during the actual laboratory period. The First hour of the laboratory
period can be used to resolve any problems the students might have experienced in completing the
Prelab exercises. The intent is to give constructive feedback so that students leave the lab with working
Prelab software - a significant accomplishment on their part. During the second hour, students
complete the In-lab exercise to reinforce the concepts learned in the Prelab. Students leave the lab
having received feedback on their Prelab and In-lab work.
Post-Lab
The last phase of each laboratory is a homework assignment that is done following the laboratory
period. In the Post-lab, students analyse the efficiency or utility of a given system call. Each Post-lab
exercise should take roughly 120minutes to complete.
LAB CONTINUOUS EVALUATION SHEET
Answer the following question before entering lab. The following pre lab task has to perform at home.
2. What are the advantages of using a DBMS over traditional file systems?
3. What is Database? Discuss the different types of database users and their roles.
In Lab:
1. Installation of PostgreSQL
Since version 8.0, PostgreSQL offers an installer for Windows systems that makes the installation process
easier and faster. For development purposes, we will install PostgreSQL version 12 or above version on
Windows 10.
Step 3: - Specify installation folder, choose your own or keep the default folder suggested by
PostgreSQL installer and click the Next button
For the tutorial on this website, you don’t need to install Stack Builder so feel free to uncheck
it and click the Next button to select the data directory:
Step 5: - Select the database directory to store the data or accept the default folder. And click the Next
button to go to the next step:
After entering the password, you need to retype it to confirm and click the Next button:
Step 7: - Enter a port number on which the PostgreSQL database server will listen. The default port of
PostgreSQL is 5432. You need to make sure that no other applications are using this port.
Step 8: - Choose the default locale used by the PostgreSQL database. If you leave it as default locale,
PostgreSQL will use the operating system locale. After that click the Next button.
Step 9: - The setup wizard will show the summary information of PostgreSQL. You need to review it and
click the Next button if everything is correct. Otherwise, you need to click the Back button to change the
configuration accordingly.
Now, you’re ready to install PostgreSQL on your computer. Click the Next button to begin installing
PostgreSQL.
Step 10: - Click the Finish button to complete the PostgreSQL installation.
✓ There are several ways to verify the PostgreSQL installation. You can try to connect to the
PostgreSQL database server from any client application e.g., psql and pgAdmin.
✓ The quick way to verify the installation is through the psql program.
First, click the psql application to launch it. The psql command-line program will display.
Second, enter all the necessary information such as the server, database, port, username, and
password. To accept the default, you can press Enter. Note that you should provide the password
that you entered during installing the PostgreSQL.
Third, issue the command SELECT version(); you will see the following output:
Post Lab:
Answer the following question before entering into lab. The following post lab task must perform at
home.
1) Describe the three-level architecture of a DBMS and its components
3) What are the key differences between a relational and object-oriented DBMS?
Answer the following question before entering into lab. The following pre lab task has to perform at
home.
1) What is the purpose of an ER diagram in database design?
6) Explain the difference between a weak relationship and a strong relationship in an ER diagram.
7) Discuss the role of constraints, such as foreign keys and primary keys, in an ER diagram.
In Lab
a. Installation of TERA ER Tool
TerraER is a free open-source learning tool designed to aid students in the creation of entity-relationship
models. Our main goal is to provide students with a tool that reflects exactly the data modelling concepts
learned in the classroom.
Introduction
Data modelling is one part of the database conceptual design process. The entity-relationship model
(ER model) is a largely used conceptual model proposed by Chen [1]. It defines the entities and the
relationships between these entities. The ER model is simple and easy to understand, making it
intelligible to both database designers and end users
Installation
TerraER is distributed in a single JAR file publicly available for download at our web
site www.terraer.com.br/download_en.html. The JAR file is auto-contained, i.e., it can be placed in any
folder, does not require the installation of additional libraries, and does not change operating system
files (e.g., windows registry). In a nutshell, TerraER requires only a Java Runtime Environment (JRE)
previously installed on the target computer (www.java.com/en/download/index.jsp).
b. COVID-19 Database
Problem Description: COVID-19 is also known as Corona Virus. It was first reported to the World
Health Organization (WHO) on the31st of December, 2019 in Wuhan, China. Mr. John employed the
services of a Data Analyst for the design of a COVID-19 database. Mr. John gave requirements to the
Data Analyst to carry on his work in designing the database. This database system is helpful in finding
out the number of cases in a particular day and in a particular country. It should also give the no. of
persons recovered or died based on the data stored in the database. By analyzing the data, we can find
out the most Covid affected areas over the globe. This system requires a database for storing the details
of all the countries with their details of country code, name, population count and such other details
related to the country. There should be Person database where all the details of the people are stored
who came for taking the test. Initially the status of the person is taken as negative. There is a need of
another database where the affected person’s data is stored. Data is inserted in to this whenever a person
is found covid positive. It should also contain the information about the recovered or death cases.
Include any other entities which are required according to your requirement.
a. What are the main entities that need to be included in the COVID-19 database?
b. What attributes should be associated with the Country entity?
c. What attributes should be associated with the Person entity?
d. Are there any additional entities or relationships that should be included in the database based
on the given requirements?
e. What are the cardinalities between the entities in the database?
f. Are there any specific data constraints or validations that should be considered in the design of
the database?
g. Draw the ER modeling for the above Problem Description.
Post Lab
Answer the following question before entering into lab. The following post lab task has to
perform at home.
a. TechCo Company Database:
Problem Description: A company named "TechCo" wants to design a database to manage their
employee information. The company has multiple departments, each with a unique department ID,
department name, and department location. Each department is managed by an employee who holds
the position of department manager.
The company employs various types of employees, including regular employees, managers, and interns.
Each employee has an employee ID, name, address, phone number, email, date of birth, and salary.
Regular employees have additional attributes such as job title and date of joining. Managers have the
same attributes as regular employees but also have a managerial role within their department.
The company provides various benefits to its employees, such as health insurance, retirement plans,
and paid time off. Each benefit has a unique benefit ID, description, and eligibility criteria.
Employees are assigned to work on different projects. Each project has a unique project ID, name, start
date, and end date. Multiple employees can be assigned to the same project, and an employee can be
assigned to multiple projects simultaneously.
In addition to the above requirements, the company wants to track the skills possessed by each
employee. Skills have a unique skill ID and a skill description. Employees can have multiple skills, and
each skill can be associated with multiple employees.
a. Draw an ER diagram representing the entities, attributes, relationships, and cardinalities based
on the given problem description.
Pre Lab:
Answer the following question before entering into lab. The following prelab task must perform at
home.
1) What is the purpose of an ER diagram in database design?
4) What is the difference between a weak entity and a strong entity in ER modeling? Provide examples
of each.
In Lab:
• Trains: The railway company operates multiple trains, each identified by a unique train number.
Each train has a name, source station, destination station, and a schedule indicating the departure
and arrival times.
• Stations: The system should store information about various stations on the railway network.
Each station has a unique station code, name, and location.
• Passengers: Passengers can book tickets by providing their personal information. Each
passenger has a unique passenger ID, name, age, gender, contact number, and address.
• Tickets: Tickets are associated with a specific passenger and train journey. Each ticket has a
unique ticket number, train number, passenger ID, journey date, and seat number.
• Seat Availability: The system should keep track of seat availability on each train for a particular
journey date. Each train has a fixed number of seats, and the availability status is updated as
passengers’ book or cancel tickets.
• Ticket Fare: The system should store the fare information for each train journey. The fare can
vary based on factors like class (e.g., general, sleeper, AC), distance, and any discounts or
promotions.
• Payment: The system should support various payment methods for ticket bookings, such as cash,
credit card, or online payment gateways. The payment information should be associated with
the respective ticket.
Design an ER diagram that represents the entities, attributes, relationships, and cardinalities for the
Railway Reservation System. Consider any necessary assumptions and justify them if required.
2. University Database:
Problem description:
In a university, there are several departments, and each department has a head of department who
belongs to Faculty. Department have a name, phone extension, specific mailing address and Students
that belong to the department. Students can belong to only one Department at a time and Department
can have more than one or no Student. Students and faculty have names and unique identification
numbers, with address, age, gender and otherinformation. Student studies different Courses offered by
university. Faculty teaches these Courses. In each semester one student can take more than one course
and Faculty can teach more than one courses. Faculty memberscan teach in multiple Departments. Each
course can be taught by many faculty members or no one. Faculty members are also working on multiple
research projects. These projects are funded by government and university.One project can have more
than one faculty member and one faculty member can work on more than one project.
• What are the main entities that need to be included in the university database system?
• What are the attributes associated with the Department entity? Are there any unique attributes
or constraints?
• What attributes should be associated with the Faculty entity? How can we represent the
relationship between faculty members and departments?
• What attributes should be associated with the Student entity? How can we represent the
relationship between students and departments?
• How can we represent the relationship between students and courses in the database system?
Can a student take multiple courses in a semester?
• How can we represent the relationship between courses and faculty members? Can a course be
taught by multiple faculty members?
• How can we represent the relationship between faculty members and departments? Can a faculty
member work in multiple departments?
• Design an ER diagram that represents the entities, attributes, relationships, and cardinalities for
the university database system.
Post Lab
Answer the following question before entering into lab. The following post lab task has to
perform at home.
1. FashionHub Retail Company Database:
Problem description:
A retail company named "FashionHub" wants to design a database to manage their product inventory
and sales. The company sells various fashion items such as clothing, accessories, and footwear. They
have multiple physical stores located in different cities.
The following information is provided to design the database:
• Products: FashionHub sells a wide range of products, including clothing, accessories, and
footwear. Each product has a unique product code, name, brand, price, and quantity in stock.
Additionally, each product belongs to a specific category (e.g., shirts, dresses, bags, shoes).
• Stores: The company operates multiple physical stores in different cities. Each store has a
unique store ID, name, address, and contact information.
• Customers: Customers can create accounts with FashionHub to make purchases. Each customer
has a unique customer ID, name, address, phone number, and email. The company also stores
information about customer preferences and purchase history.
• Sales: FashionHub keeps track of sales transactions made by customers. Each sale has a unique
sale ID, date and time, customer ID, and store ID. It also includes the total amount paid, any
discounts applied, and the payment method used (e.g., cash, credit card).
• Employees: The company employs staff members at each store. Each employee has a unique
employee ID, name, address, phone number, and position (e.g., store manager, sales associate).
Design an ER diagram that represents the entities, attributes, relationships, and cardinalities for the
FashionHub database. Consider any necessary assumptions and justify them if required.