The document is a lecture on various data models for databases, including the object oriented model, network model, hierarchical model, and relational model. It provides details on the concepts, structures, relationships, and query languages associated with each model. It also discusses mapping models to files and includes examples to illustrate concepts. The lecture is presented by Sumit Mittu and includes 41 slides.
1. INT306
Database Management Systems
OTHER DATA MODELS
Text book
Database System Concepts
A. Silberschatz, H. F. Korth, S. Sudarshan
Course Instructor
Mr. Sumit Mittu
Assistant Professor and Placement Coordinator, CSE/IT
Lovely Professional University, Punjab (India)
sumit.12735@lpu.co.in sumit.mittu@gmail.com
http://tinyurl.com/askSumit
01-03-2014 11:29:39
2. IN THIS CHAPTER
•
•
•
•
object oriented model
network model
hierarchical model
relational model
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
2
3. OBJECT ORIENTED DATA MODEL
• Need for complex data types
• Object Oriented Data Model
• Object Structure
• An object encapsulates set of variables, messages & methods
• Object Classes
• Inheritance
• Class hierarchies and Multiple inheritance
• Object Identity
• Name, value and built-in
• Object Containment
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
3
4. OBJECT ORIENTED DATA MODEL
• Object Relational (OR) Model
• Implementation in SQL (most basic implementation)
• Create an Object Type
• CREATE TYPE Engineering AS
OBJECT (Name VARCHAR(10), Roll NUMBER(8), Program VARCHAR(10));
• Create a table of objects/types
• CREATE TABLE Students OF Engineering;
• Now you can fire any queries on Stduents table just like the way
do on any other table. E.g.
•
•
•
•
DESCRIBE Students;
INSERT INTO Students Values('Priya', 25,'M.Tech');
INSERT INTO Students(Name, Program) VALUES('Kunal','B.Tech');
SELECT * FROM Students WHERE Roll IS NULL;
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
4
5. NETWORK MODEL
• A network database is a collection of records
connected to one another through links
• A record is equivalent to an entity in the E-R model
• A field/attribute in record contains only one data value
• A link is an association between precisely two records
• Data Structure Diagram
• Defined as the schema representing design of network
database
• Boxes represent record types, lines represent links
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
5
6. NETWORK MODEL
type
customer = record
customer-name: string;
customer-street: string;
customer-city: string;
01-03-2014 11:29:41
type
account = record
account-number: integer;
balance: integer;
Sumit Mittu, Assistant Professor, CSE/IT
6
18. HIERARCHICAL MODEL
• A hierarchical database is a collection of records
connected to one another through links
• The basic concepts are similar to network model but…
• Hierarchical Model supports only 1:1 and 1:N relationships
• Network Model supports 1:1, 1:N, N:1 as well as M:N relationships
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
18
19. HIERARCHICAL MODEL
• Tree Structure Diagram
• Defined as the schema representing design of hierarchical
database
• The single instance of a database tree
• The root of this tree is a dummy node
• The children of that node are actual instances of the
appropriate record type
• Boxes represent record types, lines represent links
• Record organised as rooted trees called database tree
• No cycles in underlying graphs
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
19
30. HIERARCHICAL MODEL
• Virtual Records
• It contains no data value
• It contains a logical pointer to a physical record
• Helps to overcome drawbacks raised due to replication
• Data inconsistency during update operations
• Waste of space due
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
30
32. HIERARCHICAL MODEL
• Mapping of Hierarchies to Files
• Implementation with parent-child pointers
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
32
33. HIERARCHICAL MODEL
• Mapping of Hierarchies to Files
• Implementation with leftmost-child and next-sibling pointers
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
33
34. HIERARCHICAL MODEL
• Mapping of Hierarchies to Files
• Implementation with pre-order threads
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
34
36. RELATIONAL MODEL
• Uses a collection of tables to represent both the
data and relationships among those data
• Relation/Tables
• Tuples/Records/rows of a table
• Attributes/Fields/columns of a table
• Domain of an attribute
• Atomic Domain
• NULL values
• Relation Schema (and Database Schema)
• Relation Instance (and Database Instance)
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
36
37. RELATIONAL MODEL
• A1, A2, …, An are attributes
• R = (A1, A2, …, An) is a relation schema
• Example:
• instructor = (ID, name, dept_name, salary)
• Formally, given sets D1, D2, …. Dn, a relation r is a subset of
• D1 x D2 x … x Dn
• Thus, a relation is a set of n-tuples (a1, a2, …, an) where each ai Di
• The current values (relation instance) of a relation are
specified by a table
• An element t of r is a tuple, represented by a row in a table
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
37
38. RELATIONAL MODEL
• Relational Database is based on Relational Model
• Collection of tables, each of which has a unique name
• The order of tuples in a relation (table) is irrelevant
• The order of attributes in a relation is irrelevant
• Keys:
• Super key, candidate key, primary key (entity integrity constraint)
• Foreign key (referential integrity constraint)
• Referencing relation and Referenced relation
• Also includes a DDL and DML
• Primarily SQL for data definition and manipulation
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
38
40. RELATIONAL MODEL
• Relational Database Design
• Database consists of multiple relations that contain
information about and enterprise broken up into multiple
parts
• Instructor, Student, Advisor, etc.
• Bad Design
• Repetition of information
• Missing information (due to null values)
• Normalization is required to generate good design
• Schema Diagrams
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
40
47. RELATIONAL MODEL
• Tuple Relational Calculus
• Non procedural query language
• Queries expressed as:
• { t | P(t) }
• Example queries
• { t | t є instructor ^ t[salary] > 5000 }
• { t |∃ s є instructor (t[id] = s[id] ^ s[salary] > 8000) }
• { t | ¬ (t є instructor) }
01-03-2014 11:29:41
Sumit Mittu, Assistant Professor, CSE/IT
47
48. RELATIONAL MODEL
• Domain Relational Calculus
• Non procedural query language
• Queries expressed as:
• { <x1, x2,..xn> | P(x1, x2,…,xn) }
• Example queries
• { <i, n, s> | <i, n, s> є instructor ^ s > 5000 }
• i, n and s represent the id, name and salary columns of instructor table
01-03-2014 11:29:40
Sumit Mittu, Assistant Professor, CSE/IT
48