Explain the various data models briefly with a example.
One data model can be distinguished from other on the basis of the way relationship among data, that is defined and the way the data is conceptually defined. There are many data models, chosen as per need of the application. These are fallen in following categories –
- Object-based logical models
- Record-based logical models
- Physical data models.
(i) Object-based Logical Models –
These models are used in describing data at logical and view levels. They are characterized by the fact that they provide flexible structuring capabilities and allow data constraints to specify explicitly. This model emphasizes that, everything is object having a set of attributes. There are many data models in this category –
- Entity-relationship model
- Object-oriented model.
- Functional data model
- Semantic data model
(a)Entity-relationship Model –
This model moves around three things-entity, attribute and relationship. This model is based on perception that consists of collection of objects called entities and every two entities are distinguished from other through their own set of properties. The relationship exists between these entities. E-R diagram graphically expresses the logical structure of database (schema) and it uses-
(1) Rectangles, to represent entity set
(2) Ellipses, to represent attributes
(3) Diamonds, to represent relationships among entity sets
(4) Lines, to show the links between entities and relationships.
(b) Object-oriented Model –
This model is based on a collection of objects. Object has values stored in instance variable within the object. An object also contains bodies of code that operate on the object These bodies of code are called methods. This model introduces the concept of classes that contains objects having same type of values i.e.. same set of attribute names and same methods. Values of attributes determine the object along with the methods i.e., set of instructions, that are used to modify those values. At any particular moment of time, object can be said to be the instance of the class. Two or more objects communicate each other by passing messages. The only way in which one object can access the data of another object is by invoking a method of that object. This action is called sending a message to the object. Thus, the call interface of the methods of an object defines that objects are externally visible parts. The internal parts of the object the instance variables and methods code are not visible externally. The result is two levels of data abstraction.
(ii) Record-based Logical Models-
These models are also used in describing data at logical and view levels. But in contrast to the object-based data models, they revolve around the records of the database and specify the overall structure of database, with the help of values of records. Record based models are so named, since the database is structured in fixed-format records of several types.
Each record type defines a fixed number of fields or attributes and each field is usually of a fixed length. This simplifies the physical-level implementation of the database. The three most widely used record-based models are –
- Relational model
- Network model
- Hierarchical model
(a) Relational Model-
This is most popular among the various record-based models. This model uses a collection of tables to represent both data and the relationships among those data. Each table has multiple columns and each column has unique name. Table is given the name relations, rows represent the records and the columns represent the attributes or properties.
In this model, data is handled on a conceptual rather than physical bass This mechanism helps in processing entire files of data with single statement. The logical manipulation of data also makes feasible the creation of query languages more accessible to non-technical users.
|Johnson||192-83-7465||Alma||Palo Alto||A- 201|
For example, fig. 1.3 represents a sample of relational database comprising of two tables. One table shows bank customers and other shows the account that belong to those customers. It shows, for example, that customer Johnson with social security number 192.83 * 7465 , lives on Alma in Palo Alto and has two accounts, A-101 with a balance of $500 and A-201 with a balance of $900. Also, customers Johnson and Smith share account number A-201.
(b) Network Model-
Data in network model are represented by collection of records and relationships among data are represented by links, that can be viewed as pointers. A pointer is a physical address which identifies where next record can be found on the disk. Fig. 1.4 shows a network database using the same information as shown in fig. 1.3.
(c) Hierarchical Model-
It is very similar to network model, as in both of the models, data and relationships among data are represented by records and links respectively. In this model, records are organized as collection of trees rather than arbitrary graphs. Fig. 1.5 shows hierarchical database system.
(iii) Physical Database Models-
This model is used to describe data at the lowest level i.e., to describe the behaviour of data at the disk level i.e., the way the data and data relationships are maintained while storing them on the disk. This decided the way the DBMS is going to use secondary storage devices, for storing and accessing database. The widely used these data models are-
(a)Unifying model (b)Frame memory model.