Unit 1
Unit 1
■ Updates Problem
■ Security problems
3
Basic Terminology of Database
■ Field – A character or group of characters (alphanumeric or numeric)
that has a specific meaning
■ Record – A set of one or more logically related fields
■ File – A set of related records
Input
Application
Data file
program
Output
Frontend Tools Backend Tools 4
Database Management System
■ Management System :
Management system is a collection of programs that enables
users to create and maintain the database
6
DBMS Application
■ Banking : Transactions
■ Single-user DBMS:
■ On PC – Desktop database
■ Multi-user DBMS:
■ Workgroup database (<50 users)
■ 1960s - 1970s:
■ Hard disks allow direct access to data
■ Network and Hierarchical data models in general use
■ Dr. Codd (IBM) introduced the relational data model in 1970
■ High-performance (for the era) transaction processing
■ 1980s:
■ Structure Query Language (SQL)
■ 2000s +:
■ XML and XQuery standards
■ Automated database administration
■ Increasing use of highly parallel database systems
■ Data Mining and Data Warehousing
10
Database Schema and Instances
A database model has two main components:
- Description
- Database itself
11
Database Schema and Instances
12
Database Schema and Instances
Instances or records
13
Database Architecture
Database Architecture uses programming languages to design a
particular type of software for businesses or organizations.
•One-Tier Architecture.
•Two-Tier Architecture.
•Three-Tier Architecture.
14
Database Architecture
15
Levels of Abstraction in a DBMS
16
Levels of Abstraction in a DBMS
External Schema External Schema External Schema
1 2 3
Physical Database
Schema
18
Conceptual (Logical) Schema
■ The conceptual schema describes the stored data in terms of
the data model of the DBMS.
19
Conceptual (Logical) Schema
Example: Book table
(bid: char(2), title: char(50), author: char(20), price:
decimal(5,2), av_q: integer)
20
External Schema
■ The external schema consists of the definition of the
logical records and the relationships in the external view
22
Data Independence
External Schema External Schema External Schema
1 2 3
Secondary
Storage 23
Logical Data Independence
■ Logical data independence is the capacity to change
the conceptual schema with out having to change
external schemas or application programs
25
DBMS Components
■ Data Model
■ Database languages
■ Data Definition language (DML)
■ Data Manipulation language (DDL)
26
Data Model
■ Data Model gives us an idea that how the final system will
look like after its complete implementation. It defines the
data elements and the relationships between the data
elements. Data Models are used to show how data is
stored, connected, accessed and updated in the
database management system.
■ Network Model,
■ Relational Model.
28
Hierarchical Database Model
■ Conceptual simplicity
30
Network Database Model
There are two basic data structure in the network model:
■ Records
■ Sets
31
Network Database Model
■ In network model terminology, a relationship is called a set.
33
Advantages of Network DBMSs
■ Conceptual simplicity
■ Conformance to standards
34
Disadvantages of Hierarchical
and Network DBMSs
■ Complex implementation
■ Complex data manipulation
■ Lack of data independence
■ Lack of standards (hierarchical model)
■ No widely accepted theoretical foundations
for the models
35
Relational Data Model
■ Commercial products appeared in the late 70s - earlier 80s
36
Relational Data Model
■ Basic constructs:
■ A relation
■ A record
■ A field (or a column)
■ Integrity constraints
■ Microsoft Access
■ MSSQL
■ MYSQL
■ Oracle
■ Sybase
■ DB2
■ Informix 38
Relational Algebra
■ Relational Algebra is a procedural query language. It consists of
set of operations that take one or two relations as input and
produce a new relation as their result.
■ Relational Algebra is of following eight types:
1. Select (σ )
2. Project (Π )
3. Product (X)
4. Unions (U)
5. Differences (- )
6. Intersection (∩ )
7. Join ( )
8. Divide/ Division ( / )
Data Dictionary
A Data Dictionary is a collection of names, definitions,
and attributes about data elements that are being
used or captured in a database, information system, or
part of a project.
40
Database Language
■ A language is needed to describe the database to the DBMS
as well provide facilities for changing the database and
physical data structure.
■ Most DML have built in function (SUM, COUNT and AVG etc.)
43
Difference between DBMS and RDBMS
44
Database Administrators (DBA)
■ Database administrators (DBAs) use specialized Data
base software to store and organize the data.
■ Capacity planning,
■ Installation and Configuration,
■ Database Design,
■ Performance Monitoring,
■ Security and troubleshooting,
■ Authentication or Privilege
■ Backup and Data Recovery. 45
Structure of DBMS
Query evaluation Engine
Database
Index Files
Data Dictionary
Data Files
46
Entity Relationship Model (ER Model )
■ 1976 proposed by Peter Chen
47
Basic Concepts
■ Entity - The entity is a thing or object in the world that has some independent existence with
some properties that make it differs from other. In other words entity is something that has on
identity
■ Entity set – An Entity set is a set of entities of the same type that share the same properties
or attributes. An entity set contains many entities Ex. CAR (MAURTI , TATA, etc. )
■ Weak Entity Set- An entity set which does not have a primary key
■ Relationship – specify the relations among entities from two or more entity sets
■ Domain - The Domain of an attributes is the collection of all possible values, an attribute can
48
have.
Notations of ER Diagram
49
Notations of ER Diagram
50
Example : ER Model
51
Example : ER Diagram with Weak & Storing Entity Set
52
Relationship
■ A relationship may be thought as a set as well
■ For binary relationship, it enumerates the pairs of
entities that relate to each other
53
Relationship Example
54
Attribute of A Relationship Set
55
Relationship
• The degree of a relationship = the number of
entity sets that participate in the relationship
– Mostly binary relationships
– Sometimes more
• Mapping cardinality of a relationship
– 1 –1
– 1 – many
– many – 1
– Many-many
56
One-One and One-Many
57
Many-one and many-many
58
1- many
59
Many - 1
60
Many - many
61
Total Participation
When we require all entities to participate in the relationship
(total participation), we use double lines to specify
62
Self Relationship
■ Sometimes entities in a entity set may relate to other
entities in the same set. Thus self relationship
■ Here employees mange some other employees
■ The labels “manger” and “worker” are called roles the
self relationship
63
More examples on self-relationship
■ People to people
■ Parent – Children
■ Manager – Employee
■ Husband – Wife
■ Word to word
■ Root – Synonym
64
Type of Attributes
■ Single Value Attributes (Single Ellipse)
Ex. Student Roll No.
66
Ex. ER Diagram for Entity with Attribute
67
Ex. ER Diagram for Student and Faculty
68
Ex. ER Diagram for Customer, order and Product
69
Keys
A Key is a value which can always used to unique identification
an object instance
Student Table
Roll No Name Branch Semester Remarks
1001 Ram IT 3
1002 Shyam CSE 2
1003 Nitin TT 2
A Super key is a set of one or more attributes that taken collectively
allow us to identify uniquely an entity in the entity set.
Ex. Supper Key, S=(Roll No, Name, Branch)
S=(Name , Branch, Semester)
A Candidate key can be defined as the minimum number of super key
that identifies the record uniquely. 70
Keys
■ A Primary key can be defined as the minimum number
of candidate key that is chosen by the database designer
as the principal means of identifying entities within an
entity set. There should not be any duplicate in the record
of primary key.
Ex. Primary Key, P=(Roll No)
Author
name death
birthday description
72
Generalization
■ Generalization is a relationship that exists between a
high-level entity set and lower-level entity set.
ISA
73
Example of Generalization
■ A person is a high-level entity set and customer
and employee are lower-level entity set .
74
Fig. Generalizing Car and Truck Entities
75
Specialization Inheritance and Attribute Inheritance
■ The process of designing sub groupings with an entity set is called
specialization.
Generalization
Specialization
77
Aggregation
■ Aggregation is a technique to express relationship
among relationship.
79
Extended ER Model
■ The Extended Entity Relationship Model (EER) model
include all the modeling concepts of the ER model and
the concepts of specialization , generalization,
higher-level and lower-level entity set attributes
inheritance and aggregation.
80
Relationship Degree
• The degree of a relationship type is the number of participating
entities in relation.
81
Fig. Binary and Ternary Relationship
82
Ex. Reduction of ER diagram to Table
83
Ex. Reduction of ER diagram to Table
84