3 - Data Model and Architecture-1
description
Transcript of 3 - Data Model and Architecture-1
-
1CS 222 Database Management System
Spring 2010-11
Lecture 1
Lecture 1 1
Lecture 1
Korra Sathya BabuDepartment of Computer Science
NIT Rourkela1/5/2012
Data Model A Collection of concepts that can be used to describe
the structure of a database (datatypes, relationships, and constraints that should hold on the data)
Conceptual Data Models (High level) (E-R Model, UML) Provide concepts that are close to the way many users perceive
the data
Implementation (Representational) Data Models (network, hierarchical, Relational)
Represent data by using record structures (also called record based model)
Physical Data Models (low level)(Data Structures)
Lecture 1 21/5/2012
Network Model
Lecture 1 31/5/2012
Hierarchical Model
Lecture 1 41/5/2012
Relational Model
Name Number Father Phone Address
Sri 20606001 A 2462350 Rourkela
Degree or ArityDomain
Tuple
Attibute
Siva 20606002 B 2462351 Delhi
Ran 20606003 C 2462352 Chennai
Sam 20606004 D 2462353 Vizag
Lecture 1 5
Cardinality
1/5/2012
Entity Relationship Model Notation uses three main constructs
Data entities Relationships Attributes
Entity-Relationship (E-R) Diagram A detailed, logical representation of the
entities, associations and data elements for an organization or business
6Lecture 11/5/2012
-
2Entity Relationship Model
Entity
Weak Entity
Relationship
Composite Attribute
Derived Attribute
Lecture 1 7
Attribute
Multivalued
Key Attribute
1/5/2012
Other Data Models Object Oriented Model Object Relational Model
Lecture 1 81/5/2012
Architecture
Plan Executer
File & Access Methods
Optimizer
Parser
Operator Evaluator
Transaction
Query Evaluation
Engine
Web Forms Application Front Ends SQL Interface
SQL Commands
Lecture 1 9
Buffer Manager
Disk Space Manager
Lock Manager
ManagerRecoveryManager
Concurrency Control DBMS
System Catalog
Data Files
Index FilesDatabase
1/5/2012
Relational Languages Data Model has two elements
Mathematical Notations Operations on Data
Operations on the data Abstract Operations (Uses Abstract Query Languages)
Relational Algebra, Relational Calculus (TRC, DRC)
C i l O ti ( C i l Q L ) Commercial Operations (uses Commercial Query Languages) SQL (RA, RC), QUEL (TRC), QBE (DRC)
Abstract Query Languages were proposed by Codd (1972) toreport the minimum capability of any relational query languageusing the relational model
Lecture 1 101/5/2012
Relational Algebra Procedural Language (step by step procedure for computing the
desired answer) Has Five Basic Operations
Select (): Given a relation R and a predicate P, select tuples from R that satisfy P Project (): Given a relation R and a subset of its attributes X, return a relation which is the
same as R except that all columns not in X are left out
Union (U): Given relations R1 and R2, return a relation R3 which contains all tuples in R1 and R2 Set Difference (): Given relations R1 and R2, return a relation R3 containing all tuples in R1
that are not in R2that are not in R2
Cartesian Product (X): Given 2 relations R1and R2,.return a relation R3 whosetuples are the concatenation of tuples in R1 and R2
A query Language which has the capability of expressing all theabove five operations is said to be Complete Language Ex. SQL, QBE is a query language where as dbIII+ is not a query language
Additional Operations Rename (), Assignment (), Intersection (), Join () , Division ()
Lecture 1 111/5/2012
Additional Operators in RA Join
Basic Operation: Cartesian product followed by selection or/and projection Natural Join Theta Join (conditional Join) (Equi-Join is a special case) Outer Join
Left Outer Join, Right Outer Join, Full Outer Join
Anti Join : Opposite of Join Semi Join : (R i>F S ) Defines a relation that contain the tuples of R that
participate in the join of R with Sparticipate in the join of R with S
Intersection Basic Operation: R-(R-S)
Division Operation Divides a relation R with degree m+n by a divisor relation S of degree n and
produces a result relation of degree m Basic Operation: RS = 1,2,..,r-s (R) 1,2,..,r-s ((1,2,..,r-s (R) X S) R)
where r is the arity of R and s is the arity of S
Lecture 1 121/5/2012
-
3 Aggregate operations Grouping operations
1/5/2012 Lecture 1 13
ExampleSno Sname Rating Age
22 Dustine 7 45.0
29 Brutus 1 33.0
31 Lubber 8 55.5
32 Andy 8 25.5
58 Rusty 10 35.0
Sid bid day
22 101 10/10/08
22 102 10/10/08
22 103 10/08/08
22 104 10/07/08
31 102 10/10/08
bid bname color
101 Interlake Blue
102 Interlake Red
103 Clipper Green
104 Marine red
Instance of Boats
Lecture 1 14
64 Horatio 7 35.0
71 Zorba 10 16.0
74 Horatio 9 35.0
85 Art 3 25.5
95 Bob 3 63.5
31 103 11/06/08
31 104 11/12/08
64 101 09/05/08
64 102 09/08/08
74 103 09/08/08
Instance of Sailors Instance of Reserves
1/5/2012
RA Examples1. Find Names of Sailors who have reserved boat 1032. Find the names of sailors who have reserved a red boat3. Find the color of boats reserved by Lubber4. Find the names of sailors who have reserved at least one boat5. Find the names of sailors who have reserved a red boat or a green
boat6. Find the names of sailors who have reserved at least two boats7. Find the names of sailors with age above 20 who have not
reserved a red boat8. Find the names of sailors who have reserved all boats9. Find the names of sailors who have reserved all boats called
interlake
Lecture 1 151/5/2012 Lecture 1 161/5/2012