Data models
• Object based logical model
– E-R Model
– Object Oriented Model
• Record Based Logical Model
– Network Model
– Hierarchical Model
– Relational Model
RDBMS - Relational Database
Management System)
• A database based on the relational model developed
by E.F. Codd in 1960.
• A relational database allows the definition of data
structures, storage and retrieval operations and
integrity constraints.
• Properties of Relational Tables:
– Values Are Atomic
– Each Row is Unique
– Column Values Are of the Same Kind
– The Sequence of Columns is Insignificant
– The Sequence of Rows is Insignificant
– Each Column Has a Unique Name
– All operations are performed on an entire relation and
result is an entire relation a concept known as closure
Network model
• Record based logical model
• All data is store in collection of records. And
relationship with links.
• Organized as arbitrary graph.
• So, the network model permitted the modeling of
many-to-many relationships in data. Which is not
allowed in hierarchical model.
• Thus, the complete network of relationships is
represented by several pairwise sets; in each set some
(one) record type is owner (at the tail of the network
arrow) and one or more record types are members (at
the head of the relationship arrow).
• The main difference of the network model
from the hierarchical model, is its ability to
handle many to many (N:N) relations.
• No insertion, Deletion, updation anomaly.
• But required large number of pointers.
• Making structural changes is very difficult.
• Complex retrieval.
Hierarchical Data Model
• Record based logical model
• The hierarchical data model organizes data in a tree
structure. Rather than the arbitrary graph.
• It also forms a forest.
• All data is store in record or node. And relationship with
links. And fields with branches.
• Root of the tree is dummy node.
• There is a hierarchy of parent and child data segments.
• This structure implies that a record can have repeating
information, generally in the child data segments
• This restricts a child segment to having only one parent
segment.
• Hierarchical DBMSs were popular from the late 1960s, with
the introduction of IBM's Information Management System
(IMS) DBMS, through the 1970s.
Hierarchical Data Model
• One of the oldest database models from 1950.
• Information Management System (IMS) was
developed jointly by north American Rockwell
company and IBM.
• Adv : simplicity, security, data integrity, efficiency.
• Disadv : Implementation complexity,
management Problem, Lack of structural
Independence, program complexity, operational
anomalies, Implementation limitation.
Object-Oriented Model
• The object-oriented model can be seen as extending the E-
R model with notions of encapsulation, methods
(functions), and object identity.
• Model database as a Collection of objects.
• Each object has a Data (variable) and methods (functions)
• Same data variables and same type of functions will be
grouped together to form a class.
• Object DBMSs add database functionality to object
programming languages.
Object Name
Variables
Functions
• Postgres
• Starburst
• GemStone
• ONTOS
• ObjectStore
– Application
• CAD/CAM .
• Multimedia
Other models
• Object/Relational Model
• Semistructured Model
• Associative Model
• Entity-Attribute-Value (EAV) data model
• Context Model
• http://unixspace.com/context/databases.html
Relational data Model
• Use collection of tables to represent both data
and relationship among data.
– Table known as Relation
– Each table will have unique name
– Each column will have unique name
– Attributes -> Columns
– Possible set of Values in column is domain.
– Record of one entity -> rows -> tuple.
– Degree -> number of attributes in relation.
– Cardinality -> number of tuples in relation. Number of
values.
• Domain is a set of atomic values.
• Atomic means Each value indivisible.
• All operations are performed on an entire
relation and result is an entire relation a concept
is known as closure.
• Keys
– Primary
– Candidate
– Alternative
– Super
• Integrity Rules
– 1. Entity integrity rule: if Column A is a primary key it
cannot accept null value and all values will be unique
– 2. Referential integrity rule : cannot add a value in
foreign key column if that value doesnot exist in
primary key column.
Example of a Relation
account
Attribute Types
• Each attribute of a relation has a name
• The set of allowed values for each attribute is called the
domain of the attribute.
• Attribute values are (normally) required to be atomic, that is,
indivisible
– E.g. multivalued attribute values are not atomic
– E.g. composite attribute values are not atomic
• The special value null is a member of every domain
• Domain is a set of atomic values
• Atomic means Each value indivisible.
Relation Instance
• 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
Jones
Smith
Curry
Lindsay
customer-name
Main
North
North
Park
customer-street
Harrison
Rye
Rye
Pittsfield
customer-city
customer
attributes
(or columns)
tuples
(or rows
Relations are Unordered
• Order of tuples is irrelevant (tuples may be stored in
an arbitrary order)
• E.g. account relation with unordered tuples
Database
• A database consists of multiple relations
• Information about an enterprise is broken up into parts, with each relation
storing one part of the information
E.g.: account : stores information about accounts
depositor : stores information about which customer owns
which account
customer : stores information about customers
• Storing all information as a single relation such as
bank (account-number, balance, customer-name, ..)
results in
– repetition of information (e.g. two customers own an account)
– the need for null values (e.g. represent a customer without an account)
E-R Diagram for the Banking Enterprise
The customer Relation
The depositor Relation
Keys
• Let K  R
• K is a superkey of R if values for K are sufficient to identify a
unique tuple of each possible relation r(R)
– by “possible r” we mean a relation r that could exist in the
enterprise we are modeling.
– Example: {customer-name, customer-street} and
{customer-name}
are both superkeys of Customer, if no two customers can
possibly have the same name.
• K is a candidate key if K is minimal
Example: {customer-name} is a candidate key for Customer
Determining Keys from E-R Sets
• Strong entity set. The primary key of the entity set becomes
the primary key of the relation.
• Weak entity set. The primary key of the relation consists of
the union of the primary key of the strong entity set and the
discriminator of the weak entity set.
• Relationship set. The union of the primary keys of the related
entity sets becomes a super key of the relation.
– For binary many-to-one relationship sets, the primary key
of the “many” entity set becomes the relation’s primary
key.
– For one-to-one relationship sets, the relation’s primary key
can be that of either entity set.
– For many-to-many relationship sets, the union of the
primary keys becomes the relation’s primary key
Query Languages
• Language in which user requests information from the
database. And interface b/w user and Database.
• Categories of languages
–Procedural : user has to specify what data
to get and also how to get those data.
(Procedure to obtain that data)
• Relational Algebra
–non-procedural : : user has to specify what
data to get without specifying how to get
those data.
• Relational Calculus
– Tuple Relational calculus
– Domain Relational calculus
Relational Algebra
• Procedural Query Languages.
• Operation to be performed on exciting relation to derive the result
relation.
• Unary operation.
– Select
– Project
– Rename
• Binary operation.
– Cartesian product
– Union
– Set difference
• Additional Operation
– Intersection
– Join
– Division
– Assignment

relational database

  • 1.
  • 2.
    • Object basedlogical model – E-R Model – Object Oriented Model • Record Based Logical Model – Network Model – Hierarchical Model – Relational Model
  • 3.
    RDBMS - RelationalDatabase Management System) • A database based on the relational model developed by E.F. Codd in 1960. • A relational database allows the definition of data structures, storage and retrieval operations and integrity constraints. • Properties of Relational Tables: – Values Are Atomic – Each Row is Unique – Column Values Are of the Same Kind – The Sequence of Columns is Insignificant – The Sequence of Rows is Insignificant – Each Column Has a Unique Name – All operations are performed on an entire relation and result is an entire relation a concept known as closure
  • 4.
    Network model • Recordbased logical model • All data is store in collection of records. And relationship with links. • Organized as arbitrary graph. • So, the network model permitted the modeling of many-to-many relationships in data. Which is not allowed in hierarchical model. • Thus, the complete network of relationships is represented by several pairwise sets; in each set some (one) record type is owner (at the tail of the network arrow) and one or more record types are members (at the head of the relationship arrow).
  • 5.
    • The maindifference of the network model from the hierarchical model, is its ability to handle many to many (N:N) relations. • No insertion, Deletion, updation anomaly. • But required large number of pointers. • Making structural changes is very difficult. • Complex retrieval.
  • 6.
    Hierarchical Data Model •Record based logical model • The hierarchical data model organizes data in a tree structure. Rather than the arbitrary graph. • It also forms a forest. • All data is store in record or node. And relationship with links. And fields with branches. • Root of the tree is dummy node. • There is a hierarchy of parent and child data segments. • This structure implies that a record can have repeating information, generally in the child data segments • This restricts a child segment to having only one parent segment. • Hierarchical DBMSs were popular from the late 1960s, with the introduction of IBM's Information Management System (IMS) DBMS, through the 1970s.
  • 7.
    Hierarchical Data Model •One of the oldest database models from 1950. • Information Management System (IMS) was developed jointly by north American Rockwell company and IBM. • Adv : simplicity, security, data integrity, efficiency. • Disadv : Implementation complexity, management Problem, Lack of structural Independence, program complexity, operational anomalies, Implementation limitation.
  • 8.
    Object-Oriented Model • Theobject-oriented model can be seen as extending the E- R model with notions of encapsulation, methods (functions), and object identity. • Model database as a Collection of objects. • Each object has a Data (variable) and methods (functions) • Same data variables and same type of functions will be grouped together to form a class. • Object DBMSs add database functionality to object programming languages. Object Name Variables Functions
  • 9.
    • Postgres • Starburst •GemStone • ONTOS • ObjectStore – Application • CAD/CAM . • Multimedia
  • 10.
    Other models • Object/RelationalModel • Semistructured Model • Associative Model • Entity-Attribute-Value (EAV) data model • Context Model • http://unixspace.com/context/databases.html
  • 11.
    Relational data Model •Use collection of tables to represent both data and relationship among data. – Table known as Relation – Each table will have unique name – Each column will have unique name – Attributes -> Columns – Possible set of Values in column is domain. – Record of one entity -> rows -> tuple. – Degree -> number of attributes in relation. – Cardinality -> number of tuples in relation. Number of values. • Domain is a set of atomic values. • Atomic means Each value indivisible.
  • 12.
    • All operationsare performed on an entire relation and result is an entire relation a concept is known as closure. • Keys – Primary – Candidate – Alternative – Super • Integrity Rules – 1. Entity integrity rule: if Column A is a primary key it cannot accept null value and all values will be unique – 2. Referential integrity rule : cannot add a value in foreign key column if that value doesnot exist in primary key column.
  • 13.
    Example of aRelation account
  • 14.
    Attribute Types • Eachattribute of a relation has a name • The set of allowed values for each attribute is called the domain of the attribute. • Attribute values are (normally) required to be atomic, that is, indivisible – E.g. multivalued attribute values are not atomic – E.g. composite attribute values are not atomic • The special value null is a member of every domain • Domain is a set of atomic values • Atomic means Each value indivisible.
  • 15.
    Relation Instance • Thecurrent 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 Jones Smith Curry Lindsay customer-name Main North North Park customer-street Harrison Rye Rye Pittsfield customer-city customer attributes (or columns) tuples (or rows
  • 16.
    Relations are Unordered •Order of tuples is irrelevant (tuples may be stored in an arbitrary order) • E.g. account relation with unordered tuples
  • 17.
    Database • A databaseconsists of multiple relations • Information about an enterprise is broken up into parts, with each relation storing one part of the information E.g.: account : stores information about accounts depositor : stores information about which customer owns which account customer : stores information about customers • Storing all information as a single relation such as bank (account-number, balance, customer-name, ..) results in – repetition of information (e.g. two customers own an account) – the need for null values (e.g. represent a customer without an account)
  • 18.
    E-R Diagram forthe Banking Enterprise
  • 19.
  • 20.
  • 21.
    Keys • Let K R • K is a superkey of R if values for K are sufficient to identify a unique tuple of each possible relation r(R) – by “possible r” we mean a relation r that could exist in the enterprise we are modeling. – Example: {customer-name, customer-street} and {customer-name} are both superkeys of Customer, if no two customers can possibly have the same name. • K is a candidate key if K is minimal Example: {customer-name} is a candidate key for Customer
  • 22.
    Determining Keys fromE-R Sets • Strong entity set. The primary key of the entity set becomes the primary key of the relation. • Weak entity set. The primary key of the relation consists of the union of the primary key of the strong entity set and the discriminator of the weak entity set. • Relationship set. The union of the primary keys of the related entity sets becomes a super key of the relation. – For binary many-to-one relationship sets, the primary key of the “many” entity set becomes the relation’s primary key. – For one-to-one relationship sets, the relation’s primary key can be that of either entity set. – For many-to-many relationship sets, the union of the primary keys becomes the relation’s primary key
  • 23.
    Query Languages • Languagein which user requests information from the database. And interface b/w user and Database. • Categories of languages –Procedural : user has to specify what data to get and also how to get those data. (Procedure to obtain that data) • Relational Algebra –non-procedural : : user has to specify what data to get without specifying how to get those data. • Relational Calculus – Tuple Relational calculus – Domain Relational calculus
  • 24.
    Relational Algebra • ProceduralQuery Languages. • Operation to be performed on exciting relation to derive the result relation. • Unary operation. – Select – Project – Rename • Binary operation. – Cartesian product – Union – Set difference • Additional Operation – Intersection – Join – Division – Assignment