Professional Documents
Culture Documents
6/15/2011
- B.U.Anu Barathi
Unit 1: Introduction :
Introduction to Database Database Systems Vs File Systems View of data Data Models Data base languages Transaction Management Database systems Structure History of Database Systems Database Systems Applications Entity Relationship Model
- B.U.Anu Barathi 2
6/15/2011
INTRODUCTION
What
Data Data
is Data ?
is stored facts.
may be numerical data which may be integers or floating point numbers, and non-numerical data such as characters, date and etc.,
6/15/2011
- B.U.Anu Barathi
Example:
98 89 87 92 phy chem maths biology
The above numbers may be anything: It may be distance in kms or amount in rupees or no of days or marks in each subject etc.,
6/15/2011 - B.U.Anu Barathi 4
What is information ?
Information is RELATED DATA. The data ( information) which is used by an organisation a college, a library, a bank, a manufacturing company is one of its most valuable resources.
98 89 87 92
5
What is Database ?
Database is a collection of information organized in such a way that a computer program can quickly select desired pieces of data.
98 89 87 92
76 87 79 88
86 80 79 88
91 67 87 77
6
- B.U.Anu Barathi
Database Applications:
Banking: all transactions Airlines: reservations, schedules Universities: registration, grades Sales: customers, products, purchases Online retailers: order tracking, customized recommendations Manufacturing: production, inventory, orders, supply chain Human resources: employee records, salaries, tax deductions
6/15/2011
- B.U.Anu Barathi
Security problems
Hard to provide user access to some, but not all, data
6/15/2011
- B.U.Anu Barathi
Physical level: describes how a record (e.g., customer) is stored. Logical level: describes data stored in database, and the relationships among the data.
type customer = record customer_id : string; customer_name : string; customer_street : string; customer_city : integer;
end; (PASCAL CODE)
View level: application programs hide details of data types. Views can also hide information (such as an employees salary) for security purposes.
- B.U.Anu Barathi 10
6/15/2011
6/15/2011
- B.U.Anu Barathi
11
Similar to types and variables in programming languages Schema the logical structure of the database
Example: The database consists of information about a set of customers and accounts and the relationship between them) Analogous to type information of a variable in a program Physical schema: database design at the physical level Logical schema: database design at the logical level
Physical Data Independence the ability to modify the physical schema without changing the logical schema
Applications depend on the logical schema In general, the interfaces between the various levels and components should be well defined so that changes in some parts do not seriously influence others.
6/15/2011
- B.U.Anu Barathi
12
Employee:
Eno
Ename
Salary
Address
6/15/2011
- B.U.Anu Barathi
13
Dname
Dlocation
Pname
- B.U.Anu Barathi
Hours
14
Example: Ename
A B C
Eno
1 2 3
Salary
10,000 20,000 30,000
Address
First street Second street Third street
6/15/2011
- B.U.Anu Barathi
15
Data Independence
Three schema architecture for a database system: External schema View1 View2 View n
Conceptual mapping
Disk
6/15/2011 - B.U.Anu Barathi 16
Data Independence
Two
Physical
Data Independence
Capacity to change the Internal schema without having to change external schema
6/15/2011 - B.U.Anu Barathi 17
DBMS Languages:
Types
Data Definition Language( DDL) storage definition language (SDL) storage definition language (SDL)
6/15/2011
Non-Procedural DML
- B.U.Anu Barathi 18
DBMS Languages
Data Definition Language (DDL):
Used by the DBA and database designers to specify the conceptual schema of a database. In many DBMSs, the DDL is also used to define internal and external schemas (views). In some DBMSs, separate storage definition language (SDL) and view definition language (VDL) are used to define internal and external schemas. SDL is typically realized via DBMS commands provided to the DBA and database designers
6/15/2011 - B.U.Anu Barathi 19
DBMS Languages
Data Manipulation Language (DDL):
6/15/2011
- B.U.Anu Barathi
20
Used by the DBA and database designers to specify the conceptual schema of a database. In many DBMSs, the DDL is also used to define internal and external schemas (views). In some DBMSs, separate storage definition language (SDL) and view definition language (VDL) are used to define internal and external schemas.
SDL is typically realized via DBMS commands provided to the DBA and database designers
6/15/2011 - B.U.Anu Barathi 21
Specification notation for defining the database schema Example: create table account ( account-number char(10), balance integer) DDL compiler generates a set of tables stored in a data dictionary Data dictionary contains metadata (i.e., data about data) Database schema Data storage and definition language Specifies the storage structure and access methods used Integrity constraints Domain constraints Referential integrity (references constraint in SQL) Assertions Authorization
6/15/2011
- B.U.Anu Barathi
23
Create table table name(list of attribute & their datatypes); Create schema schema name authorization author name; Drop schema schema name cascade/restrict; Drop table tablename cascade/restrict; Alter table talename add/drop Create view view name as (select ..)
6/15/2011
- B.U.Anu Barathi
24
Transaction Management
A transaction is a collection of operations that performs a single logical function in a database application Transaction-management component ensures that the database remains in a consistent (correct) state despite system failures (e.g., power failures and operating system crashes) and transaction failures. Concurrency-control manager controls the interaction among the concurrent transactions, to ensure the consistency of the database.
6/15/2011 - B.U.Anu Barathi 25
Database users
can classify users of db into many types. Nave users Application Programmers Sophisticated users Specialized users
We
6/15/2011 - B.U.Anu Barathi 26
Database users
Nave users:
application programs that have been previously written. Application Programmers: - Computer professionals who write application programs. Sophisticated users - form their requests in a db query language such as SQL and submit them to a query processor. Specialized users: - Sophisticated users who write specialized db applications
- B.U.Anu Barathi 27
6/15/2011
DBA is a person who has central control over the system. DBA is responsible for authorizing access to the db. DBA is responsible for acquiring s/w and h/w resources. DBA is responsible for coordinating and monitoring the use of db. DBA creates original db schema by executing a set of data definition stmts in DDL.
- B.U.Anu Barathi 28
6/15/2011
6/15/2011
- B.U.Anu Barathi
29
functional components can be broadly divided into the manager Query Processor.
Storage
6/15/2011
- B.U.Anu Barathi
30
Storage Manager
It is a pgm module that provides the interface b/w the low level data stored in the db and the app.pgms & queries submitted to the system. It translates the various DML statements into file system commands. It is responsible for storing, retrieving and updating data in the database.
- B.U.Anu Barathi 31
6/15/2011
Storage Manager
Authorization & Integrity Manager: - It tests for the satisfication of integrity constraints and checks the authority of users to access data. File Manager: - allocation of files and disk & data structures used to represent information stored on disk.
6/15/2011 - B.U.Anu Barathi 32
Storage Manager
Buffer
Manger:
- to decide what data to cache in mainmemory in orde to speed up the accessing of data. Transaction Manager: - db remains in a consistent state despite system failures and that concurrent transaction execution proceed without conflicting.
6/15/2011
- B.U.Anu Barathi
33
Storage Manager
The
as,
Data files which store db Data dictionary which stores meta data about the structure of the db. Indices: It is a file that provides fast access of data items that hold particular values.
6/15/2011
- B.U.Anu Barathi
34
Query Processor
It includes DDL Interpreter: - which interprets DDL sts and records the definitions in the data dictionary. DML Compiler: - It translates DML sts into an evaluation plan consisting of low level instructions that the qury evaluation engine understands. Query Evaluation Engine: -Which executes low level instructions generated by DML compiler.
- B.U.Anu Barathi 35
6/15/2011
Data Models
Relational model Entity-Relationship data model (mainly for database design) Object-based data models (Object-oriented and Objectrelational) Semistructured data model (XML) Other older models:
Network model Hierarchical model
6/15/2011
- B.U.Anu Barathi
36
Data Models
A Data
model is a set of concepts that can be used to describe the structure of the db.
A collection of Conceptual tools for describing Data Data relationships Data semantics Data constraints Different data Models - Relational model - Entity-Relationship data model (Conceptual Model-mainly for database design) - Object-based data models (Object-oriented and Object-relational) - Semi structured data model (XML) Other older models: Network model Hierarchical model
- B.U.Anu Barathi 37
6/15/2011
It is a high level conceptual data model that describes the structure of db in terms of entities, relationship among entities & constraints on them..
- Entity
-It is a an object that exists in the real world. Example: - Person, Employee, Car, Home etc..
Object with conceptual Existence - Account, loan, job etc
6/15/2011 - B.U.Anu Barathi 39
Set: - A set of entities of the same type. Attributes: - A set of properties that describe an entity.
6/15/2011 - B.U.Anu Barathi 40
Types of Attributes:
Simple (or) atomic vs. Composite: - An attribute which cant be sub divided. (Eg.Age) - An attribute which can be divided into sub parts is called as composite attribute. Address- Apartment no. e.g.. - Street - Place - City - District Single Valued vs. Multivalued: -An attribute having only one value (e.g.. Age,eid,sno) - An attribute having multiple values (e.g.. Deptlocat- A dept can be located in several places)
6/15/2011 - B.U.Anu Barathi 41
6/15/2011
- It is an association among
several entities. It specifies what type of relationship exists between entities.
6/15/2011
- B.U.Anu Barathi
43
E N T I T Y S E T
BB
2000
BB
AD
100
FFF 10000
- B.U.Anu Barathi Relationship Set
100
FFF
SD
TYPE
6/15/2011
- B.U.Anu Barathi
45
Constraints
Participation constraints
Total Participation
Partial Participation
6/15/2011
- B.U.Anu Barathi
46
a. Mapping Cardinalities:
Mapping Cardinalities OR CARDINALITY RATIOS, EXPRESSS THE NUMBER OF ENTITIES TO WHICH ANOTHER ENTITY CAN BE ASSOCIATED VIA A RELATIONSHIPSET.
Several types of Mapping Cardinalities. They are, a.i. One-to-One An entity in set A is associated with at most one entity in set B and vice versa.
e1 e2 e3
d1 d2 d3
Employee
6/15/2011
- B.U.Anu Barathi
Works for
Dept.
47
a. Mapping Cardinalities:
a.i. One-to-many An entity in set A is associated with zero or more no. of entities in set B and an entity in B is associated with at most one entity in A.
e1 e2 e3
d1 d2 d3 Works for
- B.U.Anu Barathi
Employee
6/15/2011
Dept.
48
a. Mapping Cardinalities:
a.i. Many-to-One One or more no. of entities in set A is associated with at most one entity in B. An entity in B can be associated with any no. of entities in A.
e1 e2 e3 e4 Employee
6/15/2011
d1 d2 d3 Works for
- B.U.Anu Barathi
Dept.
49
a. Mapping Cardinalities:
a.i.
Many-to-Many One or more no. of entities in set A is associated with one or more no. of entities in set B.
e1 e2 e3 e4 Employee
6/15/2011
d1 d2 d3 Works for
- B.U.Anu Barathi
Dept.
50
The participation of an entity set E in a relationship set R is said to be total if every entity in E participates in atleast one relationship in R.
Partial Participation:
an entity set E in a relationship set R is said to be partial if only a few of the entities in E participated in relationship in R.
The participation of
6/15/2011
- B.U.Anu Barathi
51
Dept.
6/15/2011
- B.U.Anu Barathi
52
Keys
It
is used to uniquely identify entities within a given entityset or a relationship set. Keys in Entity set: (i) Primary Key:
It is a key used to uniquely identify an entity in the entity set. E,g, eno,rno,dno etc
6/15/2011 - B.U.Anu Barathi 53
Keys
Super
Key: It is a set of one or more attributes that allow us to uniquely identify an entity in the entity set. Among them one must be a primary key attribute. E.G.. Eid (primary key) and ename together can be identify an entity in entity set.
6/15/2011 - B.U.Anu Barathi 54
Keys
Candidate key: They are minimal super keys for which no proper subset is a superkey. E.g.. Ename and eaddr can be sufficient to identify an employee in employee set. {eid} and {ename,eaddr} Candidate keys
6/15/2011
- B.U.Anu Barathi
55
FOREIGN Keys
An
-----------------------
attribute which makes a reference to an attribute of another entity type is called foreign key
6/15/2011
- B.U.Anu Barathi
56
Key
E.g
Foreign Key
dno
6/15/2011
dname
- B.U.Anu Barathi
dloc Dept E2
57
Domain
A range of values can be defined for an attribute and is called as Domain of that attribute.
6/15/2011
- B.U.Anu Barathi
58
no attributes, then the set of attributes Primarykey(E1) U Primarykey(E2) U Primarykey (n) Case2: If the relationship set R has attributes, then the set of attributes,
6/15/2011 - B.U.Anu Barathi 59
6/15/2011
- B.U.Anu Barathi
60
E-R Diagram
Symbol
Description
Key Attribute
6/15/2011 - B.U.Anu Barathi 61
E-R Diagram
Symbol Description
Composite Attribute
6/15/2011
- B.U.Anu Barathi
62
E-R Diagram
Symbol Description
Derived Attribute
Relationship
6/15/2011
- B.U.Anu Barathi
63
E-R Diagram
Symbol
Description
Identifying Relationship
6/15/2011
- B.U.Anu Barathi
64
E-R Diagram
Symbol
Description
R E2
Total participation of E2 in R & Partial Participation of E1 in R
E1
1 E1 R R
6/15/2011
1 E2
Min,max
Cardinality Ratio
Structural constraints (min,max) on participation of 65 Environmental in R
E2
- B.U.Anu Barathi
Recursive Relationship
If
the same entity type partcipates in a relationship more than once in different roles. E.g.. Employee
Supervise Supervisor Supervising
6/15/2011 - B.U.Anu Barathi 66
Design of an E-R Database Schema EThe steps involved in designing an E-R database schema are, Identify entity types and their entity sets. List out the attributes of each entity type. Relate several entities by specifyiing some relationship that exists among them. Specify some attributes of relation if any. Specify Generalization and specialization any exists. Specify Aggregation (global) if any used.
- B.U.Anu Barathi 67
6/15/2011
Design Process:
Functional Requirements
Functional Analysis
High level Transaction specification DBMS Independent
Conceptual Design
Conceptual schema
Logical Design
Application program Design Transaction 6/15/2011 implementation
DBMS Specific
Logical schema
Physical design
- B.U.Anu Barathi
App.pgms
Internal Schema
68
The db designers interview db users to understand & document their requirements. They find out data requirements (what data are stored in the db).
Conceptual Design:
Once the requirements are documented , the next step is to create conceptual schema which carried out in conceptual design Phase. It describes the structure of a db in the form of entity type, relationship among them & constraints.
- B.U.Anu Barathi 69
6/15/2011
Logical Design
Physical Design
The last phase is the internal storage structures, indexes, access paths, and file organizations for the db files are specified. In parallel with these activities, Application programs are designed and implemented as db transactions.
6/15/2011
- B.U.Anu Barathi
70
Using E-R model only the basic features of a db. Some enhanced features such as Specialization, Generalization, Union & aggregation can be shown using EER model.
A.
6/15/2011
- B.U.Anu Barathi
71
E.g..
eid ename Employee Mgrid eaddr Job
Typing speed
IS A
Secretary
Technician
Manager
6/15/2011
- B.U.Anu Barathi
72
It is also represented as
eid ename Employee Job Type eaddr
Defining attribute
Job
Salary Type
d
Secretary Technician Manager Hourly
d
Regular
Sub classes
6/15/2011 - B.U.Anu Barathi 73
Generalization
The
process of defining a generalized entity type from the given entity types.
- B.U.Anu Barathi 74
6/15/2011
E.g
No. of seats Vehicle ID
Vehicle ID
Tonnage
CAR
TRUCK
Max speed
Price
- B.U.Anu Barathi
No. Of Axles
Price
75
6/15/2011
Vehicle ID
Price Vehicle
d
History (cont.)
1980s:
Research relational prototypes evolve into commercial systems
SQL becomes industrial standard
1990s:
Large decision support and data-mining applications Large multi-terabyte data warehouses Emergence of Web commerce
2000s:
XML and XQuery standards Automated database administration
6/15/2011
- B.U.Anu Barathi
78
6/15/2011
- B.U.Anu Barathi
79
Relational Model:
It
uses a collection of tables to represent both data and relationships among those data. Basic Structure this model each table is called as relation. Each relation has a no. of row is called tuples and columns called as fields or attributes.
- B.U.Anu Barathi 80
In
6/15/2011
Relational Model:
For
an attribute, a range of permitted values can be specified. That range is called as Domain of that attribute. Age attribute Domain (Age) = {1,2100}
E.g..
6/15/2011
- B.U.Anu Barathi
81
Relational Model:
A
Ename
Aaa Bbb ccc
Eaddr
- B.U.Anu Barathi
Relational Model:
To
denote the value of attribute a on second tuple, then it can be denoted as t2[a]=value. E.g.. t2[ename]=bbb.
6/15/2011
- B.U.Anu Barathi
83
Relation schema
It
is the description about the structure of the relation and the relation instance is the snapshot of data in the relation at a given instant in time.
E.g.. Employee_schema=(eid,ename,eaddr) Name of the schema
6/15/2011
- B.U.Anu Barathi
84
Relation schema
6/15/2011
- B.U.Anu Barathi
85
Keys
Strong
Entity set:
The Primary key of the entity set becomes the primary key of the relation.
Weak
Entity Set:
The table corresponding a weak entity set includes the attributes of the weak entity set & primary key of the strong entity set on which the weak entity set depends.
6/15/2011 - B.U.Anu Barathi 86
Keys
Relationship Set: The union of the primary key of the related entity sets becomes a super key of the relation. Combined Tables: If there exists many to one relationship set from A to B, then the prim.key of A becomes the prim.key of the relation & the relation consists of the attribues of A and attributes of the relationship set.
6/15/2011 - B.U.Anu Barathi 87
Keys
Foreign Key: An attribute of a relation r1 that references relation r2 is called as foreign key attribute. Schema Diagram: A relation schema can be depicted pictorially by schema diagram,
6/15/2011
- B.U.Anu Barathi
88
Keys
E.g..
dloc eid
pno
89
Query Languages:
It
Query Languages
Non Procedural Language Specifies what data are Specifies what data are required without specify how required & specify how to get to get those data e.g. those data e.g Relational 6/15/2011 - B.U.Anu Barathi 90 Relational calculus Algebra Procedural Language
Relational Algebra
It consistes of a set of operations Select Project Union Set difference Intersection Cartesian Product Join Division Rename
- B.U.Anu Barathi 91
6/15/2011
Select
used.
Syntax:
6/15/2011
- B.U.Anu Barathi
92
Select
E.g..
Sal>1000 (Employee)
6/15/2011
- B.U.Anu Barathi
93
Project
It
selects attributes from the relation. II Symbol for project Syntax: ll <Attribute (table name)
list>
E.g
6/15/2011
ll Eid,sal (employee)
- B.U.Anu Barathi
Selects all tuples from emp relation & only eid & sal attributes are projected 94
Join
Natural
Join (or) Equi Join Outer Join Natural Join (or) Equi Join
- Used to combine related tuples from two relations.
- It requires that the two join attributes have the same name. - Symbol:
6/15/2011 - B.U.Anu Barathi 95
Join
Syntax:
6/15/2011
- B.U.Anu Barathi
96
Select Operation:
It
6/15/2011
- B.U.Anu Barathi
97
END OF UNIT-1 UNITReferences: Database system concepts Siberschatz, korth and sudharsan
6/15/2011
- B.U.Anu Barathi
98