Wednesday, September 1, 2010

Data Models

Data Models

A collection of conceptual tools for describing data, data relationships, data semantics, and consistency constraints

Object-based Logical Models
1. Object-based logical models:
o Describe data at the conceptual and view levels.
o Provide fairly flexible structuring capabilities.
o Allow one to specify data constraints explicitly.
o Over 30 such models, including
 Entity-relationship model.
 Object-oriented model.
 Binary model.
 Semantic data model.
 Infological model.
 Functional data model.

The E-R Model
1. The entity-relationship model is based on a perception of the world as consisting of a collection of basic objects (entities) and relationships among these objects.
o An entity is a distinguishable object that exists.
o Each entity has associated with it a set of attributes describing it.
o E.g. number and balance for an account entity.
o A relationship is an association among several entities.
o e.g. A cust_acct relationship associates a customer with each account he or she has.
o The set of all entities or relationships of the same type is called the entity set or relationship set.
o Another essential element of the E-R diagram is the mapping cardinalities, which express the number of entities to which another entity can be associated via a relationship set.


2. The overall logical structure of a database can be expressed graphically by an E-R diagram:
o rectangles: represent entity sets.
o ellipses: represent attributes.
o diamonds: represent relationships among entity sets.
o lines: link attributes to entity sets and entity sets to relationships.
.

A sample E-R diagram.




















The Object-Oriented Model
1. The object-oriented model is based on a collection of objects, like the E-R model.
o An object contains values stored in instance variables within the object.
o Unlike the record-oriented models, these values are themselves objects.
o Thus objects contain objects to an arbitrarily deep level of nesting.
o An object also contains bodies of code that operate on the the object.
o These bodies of code are called methods.
o Objects that contain the same types of values and the same methods are grouped into classes.
o A class may be viewed as a type definition for objects.
o Analogy: the programming language concept of an abstract data type.
o The only way in which one object can access the data of another object is by invoking the method of that other object.
o This is called sending a message to the object.
o Internal parts of the object, the instance variables and method code, are not visible externally.
o Result is two levels of data abstraction.
For example, consider an object representing a bank account.
o The object contains instance variables number and balance.
o The object contains a method pay-interest which adds interest to the balance.
o Under most data models, changing the interest rate entails changing code in application programs.
o In the object-oriented model, this only entails a change within the pay-interest method.


2. Unlike entities in the E-R model, each object has its own unique identity, independent of the values it contains:
o Two objects containing the same values are distinct.
o Distinction is created and maintained in physical level by assigning distinct object identifiers.






Record-based Logical Models
1. Record-based logical models:
o Also describe data at the conceptual and view levels.
o Unlike object-oriented models, are used to
 Specify overall logical structure of the database, and
 Provide a higher-level description of the implementation.
o Named so because the database is structured in fixed-format records of several types.
o Each record type defines a fixed number of fields, or attributes.
o Each field is usually of a fixed length (this simplifies the implementation).
o Record-based models do not include a mechanism for direct representation of code in the database.
o Separate languages associated with the model are used to express database queries and updates.
o The three most widely-accepted models are the relational, network, and hierarchical.

























The Relational Model
• Data and relationships are represented by a collection of tables.
• Each table has a number of columns with unique names, e.g. customer, account.
.

A sample relational database.


















The Network Model
• Data are represented by collections of records.
• Relationships among data are represented by links.
• Organization is that of an arbitrary graph.
• Following figure shows a sample network database that is the equivalent of the relational database shown before.


The Hierarchical Model
• Similar to the network model.
• Organization of the records is as a collection of trees, rather than arbitrary graphs.
• Following figure shows a sample hierarchical database that is the equivalent of the relational database shown before.

No comments:

Post a Comment