SlideShare uma empresa Scribd logo
1 de 48
Baixar para ler offline
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
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
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
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
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
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
NETWORK MODEL

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

7
NETWORK MODEL
• (a) One to many relationship
• (b) One to one relationship

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

8
NETWORK MODEL
• One to one

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

9
NETWORK MODEL
• Many to many

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

10
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

11
NETWORK MODEL

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

12
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

13
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

14
NETWORK MODEL
• Mapping of Networks to Files

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

15
NETWORK MODEL
• Mapping of Networks to Files – Ring structure

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

16
SCRATCH YOUR MIND!!!
•

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

17
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
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
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

20
HIERARCHICAL MODEL

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

21
HIERARCHICAL MODEL
• M:N relationship

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

22
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

23
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

24
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

25
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

26
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

27
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

28
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

29
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
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

31
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
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
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
SCRATCH YOUR MIND!!!
•

•

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

35
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
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
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
RELATIONAL MODEL

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

39
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
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

41
RELATIONAL MODEL
• DDL
• SQL Commands:
• CREATE, ALTER, DROP, RENAME, DESC or DESCRIBE

• DML
• Procedural
• PL/SQL Code blocks

• Declarative (Non-procedural) – Query language
• SQL Commands:
• SELECT, INSERT, UPDATE, DELETE

• Embedded SQL:
• Application programs, OLEDB/ODBC drivers, DML Pre-compilers, etc.

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

42
RELATIONAL MODEL
• Other Relational Query Languages
• Procedural v/s Non-procedural(declarative)
• “Pure” Languages
• Relational Algebra
• Relational Calculus
• Tuple Relational Calculus
• Domain Relational Calculus

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

43
RELATIONAL MODEL
• Relational Algebra Operations
•
•
•
•

Selection
Projection
Cartesian Product
Joins
• Natural join, Inner Join, Theta Join, Self Join
• Outer Join (Left / Right / Full)

• Set Operations
• Union, Intersection, Difference

• Rename, Division, etc.
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

44
01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

45
SCRATCH YOUR MIND!!!
•

01-03-2014 11:29:41

Sumit Mittu, Assistant Professor, CSE/IT

46
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
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

Mais conteúdo relacionado

Semelhante a Int306 03 (11)

Database architecture and Data modelling
 Database architecture and Data modelling Database architecture and Data modelling
Database architecture and Data modelling
 
Entity relationship modelling - DE L300
Entity relationship modelling - DE L300Entity relationship modelling - DE L300
Entity relationship modelling - DE L300
 
week1-thursday-2id50-q2-2021-2022-intro-and-basic-fd.ppt
week1-thursday-2id50-q2-2021-2022-intro-and-basic-fd.pptweek1-thursday-2id50-q2-2021-2022-intro-and-basic-fd.ppt
week1-thursday-2id50-q2-2021-2022-intro-and-basic-fd.ppt
 
ERD.ppt
ERD.pptERD.ppt
ERD.ppt
 
ERD.ppt
ERD.pptERD.ppt
ERD.ppt
 
Introduction to computers
Introduction to computersIntroduction to computers
Introduction to computers
 
Introduction to Data Analytics with R
Introduction to Data Analytics with RIntroduction to Data Analytics with R
Introduction to Data Analytics with R
 
A critical review of literature in the kenyan context
A critical review of literature in the kenyan contextA critical review of literature in the kenyan context
A critical review of literature in the kenyan context
 
A critical review of literature in the kenyan context
A critical review of literature in the kenyan contextA critical review of literature in the kenyan context
A critical review of literature in the kenyan context
 
RDBMS Model
RDBMS ModelRDBMS Model
RDBMS Model
 
RDAP14 Poster: Anything but a policy – building institutional support for dat...
RDAP14 Poster: Anything but a policy – building institutional support for dat...RDAP14 Poster: Anything but a policy – building institutional support for dat...
RDAP14 Poster: Anything but a policy – building institutional support for dat...
 

Mais de Sumit Mittu (8)

Int306 00
Int306 00Int306 00
Int306 00
 
Aca2 10 11
Aca2 10 11Aca2 10 11
Aca2 10 11
 
Aca2 09 new
Aca2 09 newAca2 09 new
Aca2 09 new
 
Aca2 08 new
Aca2 08 newAca2 08 new
Aca2 08 new
 
Aca2 07 new
Aca2 07 newAca2 07 new
Aca2 07 new
 
Aca2 06 new
Aca2 06 newAca2 06 new
Aca2 06 new
 
Aca11 bk2 ch9
Aca11 bk2 ch9Aca11 bk2 ch9
Aca11 bk2 ch9
 
Aca2 01 new
Aca2 01 newAca2 01 new
Aca2 01 new
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 

Int306 03

  • 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
  • 7. NETWORK MODEL 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 7
  • 8. NETWORK MODEL • (a) One to many relationship • (b) One to one relationship 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 8
  • 9. NETWORK MODEL • One to one 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 9
  • 10. NETWORK MODEL • Many to many 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 10
  • 11. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 11
  • 12. NETWORK MODEL 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 12
  • 13. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 13
  • 14. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 14
  • 15. NETWORK MODEL • Mapping of Networks to Files 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 15
  • 16. NETWORK MODEL • Mapping of Networks to Files – Ring structure 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 16
  • 17. SCRATCH YOUR MIND!!! • 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 17
  • 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
  • 20. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 20
  • 21. HIERARCHICAL MODEL 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 21
  • 22. HIERARCHICAL MODEL • M:N relationship 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 22
  • 23. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 23
  • 24. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 24
  • 25. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 25
  • 26. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 26
  • 27. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 27
  • 28. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 28
  • 29. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 29
  • 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
  • 31. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 31
  • 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
  • 35. SCRATCH YOUR MIND!!! • • 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 35
  • 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
  • 39. RELATIONAL MODEL 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 39
  • 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
  • 41. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 41
  • 42. RELATIONAL MODEL • DDL • SQL Commands: • CREATE, ALTER, DROP, RENAME, DESC or DESCRIBE • DML • Procedural • PL/SQL Code blocks • Declarative (Non-procedural) – Query language • SQL Commands: • SELECT, INSERT, UPDATE, DELETE • Embedded SQL: • Application programs, OLEDB/ODBC drivers, DML Pre-compilers, etc. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 42
  • 43. RELATIONAL MODEL • Other Relational Query Languages • Procedural v/s Non-procedural(declarative) • “Pure” Languages • Relational Algebra • Relational Calculus • Tuple Relational Calculus • Domain Relational Calculus 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 43
  • 44. RELATIONAL MODEL • Relational Algebra Operations • • • • Selection Projection Cartesian Product Joins • Natural join, Inner Join, Theta Join, Self Join • Outer Join (Left / Right / Full) • Set Operations • Union, Intersection, Difference • Rename, Division, etc. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 44
  • 45. 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 45
  • 46. SCRATCH YOUR MIND!!! • 01-03-2014 11:29:41 Sumit Mittu, Assistant Professor, CSE/IT 46
  • 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