0% found this document useful (0 votes)
11 views

Lab Manual 01

The document provides an introduction to database systems concepts including DBMS, RDBMS, and ORDBMS. It defines key terms like entities, attributes, tables, tuples, and domains. The objectives are to learn about database structure ADT and how to define, initialize, and refer to structure members.

Uploaded by

frazbhai28
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lab Manual 01

The document provides an introduction to database systems concepts including DBMS, RDBMS, and ORDBMS. It defines key terms like entities, attributes, tables, tuples, and domains. The objectives are to learn about database structure ADT and how to define, initialize, and refer to structure members.

Uploaded by

frazbhai28
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Lab Manual

CS130L – Database Systems Lab


Lab No: 01
Topic: Introduction

Class: BSAI
Semester: II-A
Session: Spring, 2024
Lab Instructor: Asra Masood

Lab Date: 1st Feb, 2024


Lab Time: 8:00 - 11:00

Air University Islamabad


FACULTY OF COMPUTING & ARTIFICAL INTELLIGENCE
Department of Creative Technologies
CS130L – Database Systems Lab Manual

Instructions

Submission: Use proper naming convention for your submission file. Name the submission
file as Lab_NO_DEGREE_ROLLNUM (e.g. Lab_01_BSAI_00000). Submit the file on Google
Classroom within the deadline. Failure to submit according to the above format would result in
deduction of 10% marks. Submissions on the email will not be accepted.

Plagiarism: Plagiarism cases will be dealt with strictly. If found plagiarized, both the involved
parties will be awarded zero marks in the assignment, all of the remaining assignments, or even
an F grade in the course. Copying from the internet is the easiest way to get caught!

Deadline: The deadlines to submit the assignment are hard. Late submission with marks
deduction will be accepted according to the course policy shared by the instructor. Correct and
timely submission of the assignment is the responsibility of every student; hence no relaxation
will be given to anyone.

Comments: Comment your code properly. Write your name and roll number (as a block
comment) at the beginning of the solution to each problem.
Objectives
InTip
this: lab,
For you
timely
willcompletion
learn: of the assignment, start as early as possible. Furthermore, work
smartly - as some of the problems can be solved using smarter logic.
o1. About
Note: Structure
Follow theADT.
given instructions to the letter, failing to do so will result in a zero.
o How to define a Structure, initialize and refer to individual members of a Structure.

Air University Islamabad


FACULTY OF COMPUTING & ARTIFICAL INTELLIGENCE
Department of Creative Technologies
CS130L – Database Systems Lab Manual

Objectives
In this lab, you will learn:
 DBMS, RDBMS, ORDBMS with advantages and disadvantage
 E-R Model: Analyze the problem with the entities which identify data persisted in the
database which contains entities, attributes.

Concepts
DBMS (Database Management System)
A DBMS is software that allows creation, definition and manipulation of database, allowing
users to store, process and analyze data easily. DBMS provides us with an interface or a tool, to
perform various operations like creating database, storing data in it, updating data, creating
tables in the database and a lot more.
DBMS also provides protection and security to the databases. It also maintains data consistency
in case of multiple users.
Here are some examples of popular DBMS used these days:
• MySql
• Oracle
• SQL Server
• IBM DB2
• PostgreSQL
• Amazon SimpleDB (cloud based) etc.

Characteristics of Database Management System


A database management system has following characteristics:
1. Data stored into Tables: Data is never directly stored into the database. Data is
stored into tables, created inside the database. DBMS also allows having
relationships between tables which makes the data more meaningful and
connected. You can easily understand what type of data is stored where by looking
at all the tables created in a database.
2. Reduced Redundancy: In the modern world hard drives are very cheap, but earlier
when hard drives were too expensive, unnecessary repetition of data in database
was a big problem. But DBMS follows Normalization which divides the data in such a
way that repetition is minimal.
3. Data Consistency: On Live data, i.e. data that is being continuously updated and
added, maintaining the consistency of data can become a challenge. But DBMS
handles it all by itself.
4. Support Multiple user and Concurrent Access: DBMS allows multiple users to work
on it (update, insert, and delete data) at the same time and still manages to

Air University Islamabad


FACULTY OF COMPUTING & ARTIFICAL INTELLIGENCE
Department of Creative Technologies
CS130L – Database Systems Lab Manual

maintain the data consistency.


5. Query Language: DBMS provides users with a simple Query language, using which
data can be easily fetched, inserted, deleted and updated in a database.
6. Security: The DBMS also takes care of the security of data, protecting the data from
un-authorized access. In a typical DBMS, we can create user accounts with different
access permissions, using which we can easily secure our data by restricting user
access.
7. DBMS supports transactions, which allows us to better handle and manage data
integrity in real world applications where multi-threading is extensively used.

Advantages of DBMS:
 Segregation of application program.
 Minimal data duplicity or data redundancy.
 Easy retrieval of data using the Query Language.
 Reduced development time and maintenance need.
 With Cloud Datacenters, we now have Database Management Systems capable of storing
almost infinite data.
 Seamless integration into the application programming languages which makes it very
easier to add a database to almost any application or website.

Disadvantages of DBMS:
 It's Complexity.
 Except MySQL, which is open source, licensed DBMSs are generally costly.
 They are large in size.

RDBMS (Relational Database management System)


A Relational Database management System (RDBMS) is a database management system based
on the relational model introduced by E.F Codd. In relational model, data is stored in relations
(tables) and is represented in form of tuples (rows).
RDBMS is used to manage Relational database. Relational database is a collection of organized
set of tables related to each other, and from which data can be accessed easily. Relational
Database is the most commonly used database these days.
In relational model in which data is stored in multiple tables where tables are related to each
other using primary keys and foreign keys and indexes. RDBMS uses database normalization
techniques to avoid redundancy in tables. It helps to fetch data faster using SQL query. It is
widely used by enterprises and software developers to store large amount of complex data
Examples:
• SQL server,
• Oracle
• MySQL
• MariaDB
• SQLite

Air University Islamabad


FACULTY OF COMPUTING & ARTIFICAL INTELLIGENCE
Department of Creative Technologies
CS130L – Database Systems Lab Manual

Important Concept Related to RDBMS:


Table:
In Relational database model, a table is a collection of data elements organized in terms of
rows and columns. A table is also considered as a convenient representation of relations. But a
table can have duplicate row of data while a true relation cannot have duplicate data. Table is
the simplest form of data storage. Below is an example of an Employee table.
ID Name Age Salary

1 Adam 34 13000

2 Alex 28 15000

3 Stuart 20 18000

4 Ross 42 19020

Tuple
A single entry in a table is called a Tuple or Record or Row. A tuple in a table represents a set of
related data. For example, the above Employee table has 4 tuples/records/rows.
Following is an example of single record or tuple.
1 Adam 34 13000

Attribute
A table consists of several records (row), each record can be broken down into several smaller
parts of data known as Attributes. The above Employee table consists of four
attributes, ID, Name, Age and Salary.

Attribute Domain
When an attribute is defined in a relation (table), it is defined to hold only a certain type of
values, which is known as Attribute Domain. Hence, the attribute Name will hold the name of
employee for every tuple. If we save employee's address there, it will be violation of the
Relational database model.
Name

Adam

Alex

Stuart - 9/401, OC Street, Amsterdam

Air University Islamabad


FACULTY OF COMPUTING & ARTIFICAL INTELLIGENCE
Department of Creative Technologies
CS130L – Database Systems Lab Manual

Advantages of RDBMS
 It is easy to use.
 It is secured in nature.
 The data manipulation can be done.
 It limits redundancy and replication of the data.
 It offers better data integrity.
 It provides better physical data independence.
 It offers logical database independence i.e. data can be viewed in different ways by the
different users.
 It provides better backup and recovery procedures.
 It provides multiple interfaces.
 Multiple users can access the database which is not possible in DBMS.

Disadvantages of RDBMS
 Software is expensive.
 Complex software refers to expensive hardware and hence increases overall cost to
avail the RDBMS service.
 It requires skilled human resources to implement.
 Certain applications are slow in processing.
 It is difficult to recover the lost data.

ORDBMS (Object Relational Database Management Systems)


An object relational database management system (ORDBMS) is a database management
system with that is similar to a relational database, except that it has an object-oriented
database model. This system supports objects, classes and inheritance in database schemas and
query language.
Object relational database management systems provide a middle ground between relational
and object-oriented databases. In an ORDBMS, data is manipulated using queries in a query
language. These systems bridge the gap between conceptual data modeling techniques such as
entity relationship diagrams and object relational mapping using classes and inheritance.
ORDBMSs also support data model extensions with custom data types and methods. This allows
developers to raise the abstraction levels at which problem domains are viewed.

ORDBMS Examples
Examples of ORDBMSs include:
 PostgreSQL. Open source ORDBMS developed by the PostgreSQL Global Development
Group.
 Oracle Database by Oracle Corporation.
 Informix by IBM
 SQL Server by Microsoft
 Greenplum Database by Pivotal Software

Air University Islamabad


FACULTY OF COMPUTING & ARTIFICAL INTELLIGENCE
Department of Creative Technologies
CS130L – Database Systems Lab Manual

Advantages of ORDBMS
 Reusable and Sharable – able to reuse the hard-coded components. Through database
servers those components can be shared among available resources.
 Ability of applying Objects with existing RDBMS models as it is – That is, RDBMS can be
extended with Object concepts without changing the underlying models. This leads the
organizations to switch over to ORDBMS concepts easily without performing bigger
migration or major changes.
 It allows users and programmers to start using object-oriented systems in parallel.
 Object Relational Database Management Systems ensures large storage capacity.
 Supports rich data types by adding a new object-oriented layer.
 Scalability
 Relationships are represented explicitly, often supporting both navigational and
associative access to information.
 Improved concurrency - concurrent users can safely query the same data.
 Support for Composite data types - data is bundled with its metadata.
 Improved integrity - ability to reject bad data before it is stored in an ORDBMS.
 Database extensibility - easy addition of data types and operations.
 Uniform treatment of data items - the SQL interface can perform complex queries based
on any of these data items, e.g., metadata as well as data; hence there is less need for
custom programming by users.
 Custom data access methods - e.g., R-tree indexes.
 Point-in-time recovery of data is possible.
 Built-in complex SQL functions can be provided for data operations - e.g., aggregating,
slicing, subsetting, reprojecting, etc.

Disadvantages of ORDBMS
 Complexity
 Increased cost
 Unclear if the ORDBMS will actually combine relationships and encapsulated objects to
correctly and completely mirror the ‘real world’.
Relations in RDBMS:
The Relational model allows data to be represented in a simple row- column. Each data field is
considered as a column and each record is considered as a row. Relational Database is more or
less similar to Database Management System. In relational model there is relation between
their data elements. Data is stored in tables. Tables have columns, rows and names. Tables can
be related to each other if each has a column with a common type of information.
Degree of Relationship
The Degree of Relationship indicates the link between two entities for a specified occurrence of
each.
One to One Relationship: (1:1)
Student Has Roll No.
One student has only one Rollno. For one occurrence of the first entity, there can be, at the
most one related occurrence of the second entity, and vice-versa.
Air University Islamabad
FACULTY OF COMPUTING & ARTIFICAL INTELLIGENCE
Department of Creative Technologies
CS130L – Database Systems Lab Manual

One to Many or Many to One Relationship: (1:M/M: 1) 1 :M


Course Contains Students
As per the Institutions Norm, One student can enroll in one course at a time however, in one
course, there can be more than one student.
For one occurrence of the first entity there can exist many related occurrences of the second
entity and for every occurrence of the second entity there exists only one associated
occurrence of the first.
Many to Many Relationship: (M:M) M :M
Students Appears Tests
The major disadvantage of the relational model is that a clear-cut interface cannot be
determined. Reusability of a structure is not possible. The Relational Database now accepted
model on which major database system are built.

Case Study: (Analyze the data required. Create the logical data model using E-R diagrams)
AIM: A database is to be designed for a Car Rental Co. (CRC). The information required includes
a description of cars, subcontractors (i.e. garages), company expenditures, company revenues
and customers. Cars are to be described by such data as: make, model, year of production,
engine size, and fuel type, number of passengers, registration number, purchase price,
purchase date, rent price and insurance details. It is the company policy not to keep any car for
a period exceeding one year.
All major repairs and maintenance are done by subcontractors (i.e. franchised garages), with
whom CRC has long-term agreements. Therefore the data about garages to be kept in the
database includes garage names, addresses, range of services and the like. Some garages
require payments immediately after a repair has been made; with others CRC has made
arrangements for credit facilities. Company expenditures are to be registered for all outgoings
connected with purchases, repairs, maintenance, insurance etc.
Similarly the cash inflow coming from all sources - car hire, car sales, insurance claims - must be
kept in file. CRC maintains a reasonably stable client base. For this privileged category of
customers special credit card facilities are provided. These customers may also book in advance
a particular car. These reservations can be made for any period of time up to one month. Casual
customers must pay a deposit for an estimated time of rental, unless they wish to pay by credit
card. All major credit cards are accepted. Personal details (such as name, address, telephone
number, driving license, number) about each customer are kept in the database.

Air University Islamabad


FACULTY OF COMPUTING & ARTIFICAL INTELLIGENCE
Department of Creative Technologies

You might also like