Database Unit1 Notes For Reference
Database Unit1 Notes For Reference
What is Database?
The database is a collection of inter-related data which is used to retrieve, insert and delete the
data efficiently. It is also used to organize the data in the form of a table, schema, views, and
reports, etc.
o For example: MySQL, Oracle, etc are a very popular commercial database
which is used in different applications.
o DBMS provides an interface to perform various operations like database
creation, storing data in it, updating data, creating a table in the database
and a lot more.
o It provides protection and security to the database. In the case of multiple
users, it also maintains data consistency.
Data Abstraction is a process of hiding unwanted or irrelevant details from the end
user. It provides a different view and helps in achieving data independence which is
used to enhance the security of data.
2. Conceptual or Logical level: The conceptual level describes the structure of the whole
database. This level acts as a middle layer between the physical storage and user view. It
explains what data to be stored in the database, what relationship exists among those data, and
what the datatypes are. There is only one conceptual schema per database.
At conceptual level, data is represented in the form of various database tables. For Example,
STUDENT database may contain STUDENT and COURSE tables which will be visible to users but
users are unaware of their storage.Also referred as logical schema,it describes what kind of data
is to be stored in the database.
3. Internal or Physical level: This is the lowest level of database abstraction. It describes how
the data is actually stored in the database and provides methods to access data from the
database. It allows viewing the physical representation of the database on the computer
system.
1.
=============================----------------------------===============
Physical Data Independence: Any change in the physical location of tables and indexes should
not affect the conceptual level or external view of data.
Conceptual Data Independence: The data at conceptual level schema and external level schema
must be independent. This means a change in conceptual schema should not affect external
schema. e.g.; Adding or deleting attributes of a table should not affect the user’s view of the
table.
A DBMS provides necessary database languages that allow users to express database updates
and queries, which are requests for data.
SQL is the standard language for dealing with Relational Databases. SQL can be used to insert,
search, update, and delete database records.
Data control language (DCL) controls access to the data that users store within a
database. Essentially, this language controls the rights and permissions of the
database system. It allows users to grant or revoke privileges to the database.
Here's a list of DCL statements:
====================---------------------------==========================
DBMS Architecture
o The DBMS design depends upon its architecture. The basic client/server
architecture is used to deal with a large number of PCs, web servers, database
servers and other components that are connected with networks.
o The client/server architecture consists of many PCs and a workstation which are
connected via the network.
o DBMS architecture depends upon how users are connected to the database to
get their request done.
2-Tier Architecture
o The 2-Tier architecture is same as basic client-server. In the two-tier architecture,
applications on the client end can directly communicate with the database at the
server side. For this interaction, API's like: ODBC, JDBC are used.
o The user interfaces and application programs are run on the client-side.
o The server side is responsible to provide the functionalities like: query processing
and transaction management.
o To communicate with the DBMS, client-side application establishes a connection
with the server side.
3-Tier Architecture
o The 3-Tier architecture contains another layer between the client and server. In
this architecture, client can't directly communicate with the server.
o The application on the client-end interacts with an application server which
further communicates with the database system.
o End user has no idea about the existence of the database beyond the application
server. The database also has no idea about any other user beyond the
application.
o The 3-Tier architecture is used in case of large web application.
============================-------------------------------===========
Data Models
Data Model is the modeling of the data description, data semantics, and
consistency constraints of the data. It provides the conceptual tools for
describing the design of a database at each level of data abstraction. Therefore,
there are following four data models used for understanding the structure of the
database:
1) Relational Data Model: This type of model designs the data in the form of rows and columns
within a table. Thus, a relational model uses tables for representing data and in-between
relationships. Tables are also called relations. This model was initially described by Edgar F.
Codd, in 1969. The relational data model is the widely used model which is primarily used by
commercial data processing applications.
4) Semistructured Data Model: The semistructured data model allows the data specifications at
places where the individual data items of the same type may have different attributes sets. The
Extensible Markup Language, also known as XML, is widely used for representing the
semistructured data.
=============================-=------------------------------------------==========
What is ER model?
ER model
o ER model stands for an Entity-Relationship model. It is a high-level data model.
This model is used to define the data elements and relationship for a specified
system.
o It develops a conceptual design for the database. It also develops a very simple
and easy to design view of data.
o In ER modeling, the database structure is portrayed as a diagram called an entity-
relationship diagram.
For example, Suppose we design a school database. In this database, the student will be an
entity with attributes like address, name, id, age, etc. The address can be another entity with
attributes like city, street name, pin code, etc and there will be a relationship between them.
1. Entity:
An entity may be any object, class, person or place. In the ER diagram, an entity
can be represented as rectangles.
An entity that depends on another entity called a weak entity. The weak entity doesn't contain
any key attribute of its own. The weak entity is represented by a double rectangle.
2. Attribute
The attribute is used to describe the property of an entity. Eclipse is used to represent an
attribute.
For example, id, age, contact number, name, etc. can be attributes of a student.
a. Key Attribute
b. Composite Attribute
d. Derived Attribute
For example, A person's age changes over time and can be derived from another attribute like
Date of birth.
3. Relationship
A relationship is used to describe the relation between entities. Diamond
or rhombus is used to represent the relationship.
========================------------------------------------===============================
================================--------------------------------===========================
Relational algebra is a procedural query language that works on relational model. The purpose
of a query language is to retrieve data from database or perform various operations such as
insert, update, delete on the data.
The SELECT operation is used for selecting a subset of the tuples according to a given selection
condition. Sigma(σ)Symbol denotes it. It is used as an expression to choose tuples which meet
the selection condition. Select operator selects tuples that satisfy a given predicate.
Example--
Example---
Join Operation –
==============-------------------------=================================
Relational calculus is a non-procedural query language that tells the system what data to be
retrieved but doesn’t tell how to retrieve it.
==================================----------------------------====================