0% found this document useful (0 votes)
35 views83 pages

Dbms Unit 1 Koushik

The document provides a high-level summary of the following topics related to database management systems: 1. It introduces database systems and their purpose of organizing data for easy access, management, and updating. 2. It discusses database models including relational databases and data abstraction levels. 3. It covers database design concepts such as the entity-relationship model and entity-relationship diagrams.

Uploaded by

GRASH KJT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views83 pages

Dbms Unit 1 Koushik

The document provides a high-level summary of the following topics related to database management systems: 1. It introduces database systems and their purpose of organizing data for easy access, management, and updating. 2. It discusses database models including relational databases and data abstraction levels. 3. It covers database design concepts such as the entity-relationship model and entity-relationship diagrams.

Uploaded by

GRASH KJT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 83

Database Management Systems

Unit 1
Introduction to Database system: purpose of database system, view of data,
Independence, relational databases, -Database Language-Database System
architecture- levels, Mappings, Database, users and DBA Data Models: Importance,
Basic building blocks, Degrees of data abstraction. Database design and ER Model:
Overview, ER-Model, Constraints, ERDiagrams, ERD Issues, weak entity sets.
• Data is nothing but facts and statistics stored or free flowing over a
network, generally it's raw and unprocessed.

• For example: When you visit any website, they might store you IP
address, that is data, in return they might add a cookie in your browser,
marking you that you visited the website, that is data, your name, it's
data, your age, it's data.

• Data becomes information when it is processed, turning it into


something meaningful.
Database
• A Database is a collection of related data organised in a way that data
can be easily accessed, managed and updated. Database can be
software based or hardware based, with one sole purpose, storing
data.

• During early computer days, data was collected and stored on tapes,
which were mostly write-only, which means once data is stored on it,
it can never be read again. They were slow and bulky, and soon
computer scientists realised that they needed a better solution to this
problem.
• A DBMS is a software that allows creation, definition and manipulation of database, allowing users to store, process and
analyse 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:
• Data stored into Tables: 
• Data is never directly stored into the database. Data is stored into
tables, created inside the database.
• DBMS also allows to have relationships between tables which makes
the data more meaningful and connected.
• 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 Normalisation which divides the data in such a way that
repetition is minimum.
• 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.
• Support Multiple user and Concurrent Access: DBMS allows multiple
users to work on it(update, insert, delete data) at the same time and
still manages to maintain the data consistency.
• Query Language: DBMS provides users with a simple Query language,
using which data can be easily fetched, inserted, deleted and updated
in a database.
• Security: The DBMS also takes care of the security of data, protecting
the data from un-authorised 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.
• 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(all in one) 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.
• Components of DBMS
• The database management system can be divided into five major
components, they are:
• Hardware
• Software
• Data
• Procedures
• Database Access Language
• DBMS Components: Hardware
• When we say Hardware, we mean computer, hard disks, I/O channels
for data, and any other physical component involved before any data
is successfully stored into the memory.
• When we run Oracle or MySQL on our personal computer, then our
computer's Hard Disk, our Keyboard using which we type in all the
commands, our computer's RAM, ROM all become a part of the
DBMS hardware.
• DBMS Components: Software
• This is the main component, as this is the program which controls everything.
• The DBMS software is more like a wrapper around the physical database, which
provides us with an easy-to-use interface to store, access and update data.

• The DBMS software is capable of understanding the Database Access Language


and interpret it into actual database commands to execute them on the DB.
• DBMS Components:
• Data
• Data is that resource, for which DBMS was designed. The motive behind the creation of DBMS was
to store and utilise data.
• In a typical Database, the user saved Data is present and meta data is stored.
• Metadata is data about the data. This is information stored by the DBMS to better understand the
data stored in it
•.
• For example: When I store my Name in a database, the DBMS will store when the name was
stored in the database, what is the size of the name, is it stored as related data to some other
data, or is it independent, all this information is metadata.
• DBMS Components:
• Procedures
• Procedures refer to general instructions to use a database
management system. This includes procedures to setup and install a
DBMS, To login and logout of DBMS software, to manage databases,
to take backups, generating reports etc.
• DBMS Components:
• Database Access Language
• Database Access Language is a simple language designed to write
commands to access, insert, update and delete data stored in any
database.
• A user can write commands in the Database Access Language and
submit it to the DBMS for execution, which is then translated and
executed by the DBMS.
• User can create new databases, tables, insert data, fetch stored data,
update data and delete the data using the access language.
• Users
• Database Administrators: Database Administrator or DBA is the one who manages the complete
database management system. DBA takes care of the security of the DBMS, it's availability, managing
the license keys, managing user accounts and access etc.

• Application Programmer or Software Developer: This user group is involved in developing and


designing the parts of DBMS.

• End User: These days all the modern applications, web or mobile, store user data. How do you think
they do it? Yes, applications are programmed in such a way that they collect user data and store the
data on DBMS systems running on their server. End users are the one who store, retrieve, update and
delete data.
Database Management Systems
Topic: Database Models
DBMS Database Models:
• A Database model defines the logical design and structure of a
database and defines how data will be stored, accessed and updated
in a database management system. While the Relational Model is the
most widely used database model, there are other models too:
• Hierarchical Model
• Network Model
• Entity-relationship Model
• Relational Model
Hierarchical Model
• This database model organises data into a tree-like-structure,
with a single root, to which all the other data is linked.
• The hierarchical starts from the Root data, and expands like a
tree, adding child nodes to the parent nodes.
• In this model, a child node will only have a single parent node.
• This model describes many real-world relationships like
example index of a book.
• In hierarchical model, data is organised into tree-like structure
with one-to-many relationship between two different types of
data, for example, one department can have many courses,
many professors and many students.
Hierarchical Model
E-R Model (Entity-relationship Model)
• ER Model describes the structure of a database with the help of a
diagram known as “Entity Relationship Diagram”
• The basic use of ER Model is to represent the structure of database
diagrammatically is called Er model
• An ER diagram shows the relationship among entity sets.
• Normally in database the data's are stored in Tables format.
• ER diagram shows the relationship between the tables.
• An entity set is a group of similar entities and these entities can have
attributes.
• Attributes are nothing but the columns in the table.
• ER diagram shows the complete “logical structures” of a database.
• ER diagrams has three main components:
Entity
Attribute
Relationship
1. Entity:
• An entity is as object or component of data.
• An entity is represented as “Rectangle” in an ER diagram.
• Example for entity:

STUDENT COLLEGE

• Weak Entity
• An entity that cannot be uniquely identified by its own attributes and relies
on the relationship with other entity is called “Weak Entity”
• Entity cannot be identified uniquely even though by its attribute. But it can be identified
by its relationship with other Entity is called “Weak Entity”
• An Week Entity is represented as “Double Rectangle” in an ER diagram
BANK ACCOUNT. No BANK

• A Bank Account Number cannot be uniquely identified without


knowing the bank to which the account belongs to, so bank account
number is a Weak entity.
2. Attribute:
• An Attribute describes the property of an entity.
• An attribute is represented as “Ovel” in an ER diagram.
• There are four types of Attributes
• Primary Key Attribute
• Composite Attribute
• Multivalued Attribute
• Derived Attribute Name Age

• Example:

Reg. No Student Address


• Primary Key Attribute
• A Key attribute can uniquely identify an entity from an entity set.
• Key attribute is represented by Ovel same as other attributes however the
“text of key attribute is underlined”.
• Example of Primary Key Attribute:

Name Age

Reg. No Student Address


• Composite Attribute:
• An attribute that is a combination of other attribute is known as
“Composite Attribute”.
• Address is a Composite attribute. Pin Code

Student Address

State

Country

• For Example, In student entity, the student address is a Composite


attribute as an address is composed of other attributes such as Pin
code, State and Country
• Multivalued Attribute:
• An Attribute that can hold multiple values is knows as “ Multivalued
Attribute”.
• It is represented with “Double Ovals” in an ER diagram.

• For Example, a person can have more Name

than one phone numbers. So the


Phone.NO
Phone. No Reg.No
phone number attribute is
Multivalued Attribute.
Student
• Derived Attribute:
• A Derived Attribute is one whose value is dynamic and derived from
another Attribute.
• It is represented by “Dashed ovel”.
• Example of Derived Attribute:

Name Age Phone.


Phone.NO
No

Reg. No Student Date of Birth

• Age is a Derived attribute because it can be derived from DoB.


• Age = Current Date – Date of Birth.
E-R Diagram With Composite, Multivalued, and Derived
Attributes
3. Relationship:
• It helps to show the relationship among entities.
• A relationship is represented by diamond shaped in ER diagram.
• There are three types of relationship:
Binary relationship
Recursive relationship
Ternary relationship
• Binary relationship:
• Binary relationship means relation between two entity.
• This is further divided in to four types
One to one relationship
One to many relationship
Many to one relationship
Many to many relationship
• One to one relationship:
• When a single instance of an entity is associated with a single instance
of another entity then it is called “One to one relationship”.

1 1
Person has Passport

• For example, a person has only one passport and a passport is given
to one person.
• One to Many relationship:
• When a single instance of an entity is associated with more than one
instance of another entity, then it is called “One to Many
relationship”.

1 M
Customer placed Order

• For example, a customer can place many orders but a order cannot
placed by many customer.
• Many to One relationship:
• When more than one instance of an entity is associated with single
instance of another entity, then it is called “Many to One
relationship”.

M 1
Student Study College

• For example, many student can study in a single college but a student
cannot study in many college at the same time.
• Many to Many relationship:
• When more than one instance of an entity is associated with more
than one instance of another entity, then it is called “Many to Many
relationship”.

M M
Student Assigned Project

• For example, a student can be assigned to many projects and a


projects can be assigned to many students.
E-R Diagram with a Ternary Relationship
• For example, in the diagram above, we have three related
entities, Company, Product and Sector. To understand the relationship
better or to define rules around the model, we should relate two entities
and then derive the third one.
• A Company produces many Products/ each product is produced by exactly
one company.
• A Company operates in only one Sector / each sector has many companies
operating in it.
• Considering the above two rules or relationships, we see that although the
complete relationship involves three entities, but we are looking at two
entities at a time.
E-R Diagram for a Banking Enterprise
Summary of Symbols Used in E-R Notation
Summary of Symbols (Cont.)
ER Model to Relational Model
• Some of the methods are automated and some of then are manual.
• ER diagrams mainly comprises of:
• Entity and its Attributes
• Relationship which is association among entity
• To know about Relational model is communication between one entity to
another entity.
• This relational model can be represented by using “Mapping Entity”.
• Mapping process for a single Entity:
• Create table for each entity
• Entities attribute should become fields of tables with respective datatypes.
• Declare primary key.
Basic Concepts of ER Model in DBMS

• Entity-relationship model is a model used for design and representation of


relationships between data.
• The main data objects are termed as Entities, with their details defined as
attributes, some of these attributes are important and are used to identity
the entity, and different entities are related using relationships.
• In short, to understand about the ER Model, we must understand about:
• Entity and Entity Set
• What are Attributes? And Types of Attributes.
• Keys
• Relationships
Entity and Entity Set

• Considering the above example, Student is an entity, Teacher is an


entity, similarly, Class, Subject etc are also entities.
• An Entity is generally a real-world object which has characteristics and
holds relationships in a DBMS.

• If a Student is an Entity, then the complete dataset of all the students


will be the Entity Set
Attributes
• If a Student is an Entity, then student's roll no.,
student's name, student's age, student's gender etc will
be its attributes.

• An attribute can be of many types, here are different


types of attributes defined in ER database model:

• Simple attribute: The attributes with values that are


atomic and cannot be broken down further are simple
attributes. For example, student's age.
• Composite attribute: A composite attribute is made up of more than one simple
attribute.
• For example, student's address will contain, house no., street name, pincode etc.

• Derived attribute: These are the attributes which are not present in the whole
database management system, but are derived using other attributes. For
example, average age of students in a class.

• Single-valued attribute: As the name suggests, they have a single value.

• Multi-valued attribute: And, they can have multiple values.


Student
Name Class
Reg. No Name Class Subject

Reg. No Student Subject

• Declare each field with a data types


• Reg.no: int and char, Name : char, Class : char and Subject: Char.

• Entity in ER model is the table name in relational model


• Attributes are the first column in the relational table
• The rows filles in the tables are called as domain.
Mapping Relationship in Relational Model
• Relationship is an association among entities.

Joining Course
Name Reg.No Marks Title
Date ID

Enroll
Student Course
ed
• Mapping Process:
• Create table for a relationship (that is for Enrolled)
• Add Primary Key of all participants entities as fields with respective
datatype.
• If relationship has any attribute , then add each attribute as field of a
table
• Declare Primary Key
• There are two entity and by declaring Primary Key in one entity, with
that Primary Key search in another entity that key will act as Foreign
key.
Relational Database Management System
(RDBMS)
• Relational model is a model in which data is maintained in a
table/Relation.
• Relational data base is most commonly used database. It contains
number of tables and each table has its own primary key.
• Due to a collection of organized set of table data can be accessed easily
in RDBMS.
• A table is a collection of related data entries and contain rows and
columns to store data.
• But a table can have duplicate tuples while a true relation cannot have
duplicate tuples.
What is a Table and Field/Column?
ID Name Age Course
1 AAA 21 Computer
2 BBB 22 Mathematics
3 CCC 24 Physics
4 DDD 25 Chemistry

• Every table is broken up in to small entities called fields.


The fields in the student table consist of ID, Name, Age and Course.
• A field is a Column in a table that is designed to maintain specific
information about every record in the table.
What is Row/Record/Tuples and
Column/Attributes?
• It contains the specific information of each individual entry in the
table. It is a horizontal entry in the table.
• For example the previous student table contains 4 records.
ID Name Age Course
1 AAA 21 Computer

• A column is a vertical entity in the table which contains all information


associated with a specific field in a table. ID

• Columns of a relation/table must have distinct names. 1


2
3
4
• NULL Value:
• A NULL Value in a table is a value in a field that appears to be blank,
which means a field with a NULL Value is a field with no value.
• It is very important to understand that a NULL Value id different than
a Zero value or a field that contains spaces. A field with a Null Value is
the one that has been left blank during record creation.
• Degree of a Table:
• Number of attributes in a relation or table determine the “degree of a
relation “ (no. of column).
ID Name Age Course
1 AAA 21 Computer

• Example : Degree of above table = 4(ID, Name, Age and Course).


Schema Diagram for University Database
Keys:
• Keys play an important role in the relational database.
• It is used to uniquely identify any record or row of data from the table. It
is also used to establish and identify relationships between tables.
• Following are the types of Keys:
• Primary Key
• Candidate Key
• Super Key
• Foreign Key
• Composite Key
Need of a key
• Tables store a lot of data in them. Tables generally extends to
thousands of records stored in them, unsorted and unorganised.
• Now to fetch any particular record from such dataset, you will have to
apply some conditions, but what if there is duplicate data present and
every time you try to fetch some data by applying certain condition,
you get the wrong data. How many trials before you get the right
data?
• To avoid all this, Keys are defined to easily identify any row of data in
a table.
1. Primary key
• It is the first key used to identify one and only one instance of an
entity uniquely. An entity can contain multiple keys. The key which is
most suitable from those lists becomes a primary key.
• In the EMPLOYEE table, ID can be the primary key since it is unique
for each employee. In the EMPLOYEE table, we can even select
License_Number and Passport_Number as primary keys since they are
also unique.
• For each entity, the primary key selection is based on requirements and
developers.
2. Candidate key
• A candidate key is an attribute or set of attributes that can uniquely
identify a tuple.
• Except for the primary key, the remaining attributes are considered a
candidate key. The candidate keys are as strong as the primary key.

Candidate Key
3. Super Key
• Super key is an attribute set that can uniquely identify a tuple. A super
key is a superset of a candidate key.

• For example: In the above EMPLOYEE table, for(EMPLOYEE_ID,


EMPLOYEE_NAME), the name of two employees can be the same,
but their EMPLYEE_ID can't be the same. Hence, this combination
can also be a key.
4. Foreign key
• Foreign keys are the column of the table used to point to the primary
key of another table.
• Every employee works in a specific department in a company, and
employee and department are two different entities. So we can't store
the department's information in the employee table. That's why we link
these two tables through the primary key of one table.
• We add the primary key of the DEPARTMENT table, Department_Id,
as a new attribute in the EMPLOYEE table.
• In the EMPLOYEE table, Department_Id is the foreign key, and both
the tables are related.
• Foreign key example:
DBMS Architecture
• 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.
• The client/server architecture consists of many PCs and a workstation
which are connected via the network.
• DBMS architecture depends upon how users are connected to the
database to get their request done.
Types of DBMS Architecture
• 1-Tier Architecture
• In this architecture, the database is directly available to the user. It
means the user can directly sit on the DBMS and uses it.
• Any changes done here will directly be done on the database itself. It
doesn't provide a handy tool for end users.
• The 1-Tier architecture is used for development of the local
application, where programmers can directly communicate with the
database for the quick response.
• 2-Tier Architecture
• 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.
• The user interfaces and application programs are run
on the client-side.
• The server side is responsible to provide the
functionalities like: query processing and
transaction management.
• To communicate with the DBMS, client-side
application establishes a connection with the server
side.
• 3-Tier Architecture
• The 3-Tier architecture contains another layer
between the client and server. In this architecture,
client can't directly communicate with the server.
• The application on the client-end interacts with an
application server which further communicates
with the database system.
• 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.
• The 3-Tier architecture is used in case of large
web application.
Data model Schema and Instance
• The data which is stored in the database at a particular moment of time is called an
instance of the database.
• The overall design of a database is called schema.
• A database schema is the skeleton structure of the database. It represents the logical
view of the entire database.
• A schema contains schema objects like table, foreign key, primary key, views, columns,
data types, stored procedure, etc.
• A database schema can be represented by using the visual diagram. That diagram
shows the database objects and relationship with each other.
• A database schema is designed by the database designers to help programmers whose
software will interact with the database. The process of database creation is called data
modeling.
• A schema diagram can display only some aspects of a schema like the
name of record type, data type, and constraints. Other aspects can't be
specified through the schema diagram. For example, the given figure
neither show the data type of each data item nor the relationship
among various files.
Data Independence
• Data independence can be explained using the three-schema
architecture.( Physical, logical and
• Data independence refers characteristic of being able to modify the
schema at one level of the database system without altering the
schema at the next higher level.
• There are two types of data independence:
1. Logical Data Independence
2. Physical Data Independence
• 1. Logical Data Independence
• Logical data independence refers characteristic of being able to change
the conceptual schema without having to change the external schema.
• Logical data independence is used to separate the external level from
the conceptual view.
• If we do any changes in the conceptual view of the data, then the user
view of the data would not be affected.
• Logical data independence occurs at the user interface level.
•  Physical Data Independence:
• Physical data independence can be defined as the capacity to change
the internal schema without having to change the conceptual schema.
• If we do any changes in the storage size of the database system server,
then the Conceptual structure of the database will not be affected.
• Physical data independence is used to
separate conceptual levels from the internal
levels.
• Physical data independence occurs at the
logical interface level.
Reduction of ER diagram to Table

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy