Database is built on a well defined structure called a data model. Data models are characterized by providing the ability to create data items. It additionally allows defining relationships between data items, semantics of data, rules, constraints and other attributes of data. More specifically we can say that a data model is a technique of defining organization, storage and retrieval mechanism in a database.
It can also be described as a conceptual tool to describe the data, the relationship between data, semantics and integrity constraints.
There are two basis of data models
- Object based
- Record Based
Object Based Data Model
Object based data model is also known as the logical model. Entity relationship model is a kind of object based data model. It describes the entities, their attributes and their relationship.
An Entity is anything which exists or happens. It can be an object, individual, event or process. It is anything about which we need to collect and manage the data. Any specific member of the entity set is called an entity instance. For example a “Customer” is an entity about which the sales department wants to collect data. “James” is one of the customers and is an entity instance. “Order” is another entity in the same environment.
Attributes define an entity in the specific application. An entity “Customer” can have attributes like name, address and a contact number. The entity “Customer” can have relationship (Places) with entity “Order”. “Order” entity can have the relationship (Placed by) with “Customer” entity.
Record Based Data Models
There are three models based on records- Hierarchical, Network and Relational.
When files system posed the issues of inconsistency, data dependence and inflexibility, hierarchical data model came into existence. The name is given because the records are arranged in a tree like structure.
The parent records in hierarchy store the address of all the child records using the pointers. A parent record can have many child records but a child record will be related to only one parent. The records at same level of hierarchy cannot have any connectivity. Users could locate a specific record by following the hierarchy starting from root record. Hierarchical model allows only 1:N relationship among entities.
In the above example the “Professor” Record is root record and it is related to three records “Student”, “Courses” and “Qualifications”. Its child record “Student” is related to “Projects” and “Courses” records. Here the “courses” record exists twice in the model since there can’t be any other relationship than parent and child.
- The organization of database emulates a tree structure is easy to understand.
- Users can access or update records in very less time due to well defined relationships.
- Due to tree like hierarchy this kind of model requires huge index files for managing and fast access of data.
- Relationships can only be of parent child nature so duplicity of records leads to larger storage need.
- Alteration of tables is difficult since it could affect the records at all the levels below a record.
- Adding a new relationship is also a difficult process.
Network Data Model
Network data models are based on graphical linking that represents the relationships among entities through edges. A network database can be treated as a collection of records connected with links. One record stores links (pointers to) of other records. So, one record can be parent to many records and one child record can have many parents. Network data model allows M:N relationship among records. The data relationships are represented by membership sets.
Here the records “Professor” and “Student” share the “Courses” and “Projects” records then giving a M:N relationship.
- Network model is better representation of real world data due to many to many relationships.
- This model is flexible and provides better access to data since one can access any record related to one record.
- Data integrity can be enforced because only those records can be accessed which are contained in the membership set of a record.
- Redundancy is reduced.
- The complex record structure can be difficult to implement in an application.
- Complicated relationships are a big drawback of Network Data Model
Relational Model was proposed by E F Codd. It gives an efficient and simple data model in comparison to Network and Hierarchical data models.
The relational data models are based on relations (tables) and the relationships among relations. Each relation is defined by more than one attributes (columns), having a unique name. The relations are collection of tuples (records) of a particular type. The relational model operations are based on relational algebra that defines operations like join, union, intersection and projection between the tuples of relations.
Relational data model uses keys to uniquely identify the tuples in relations. These also enforce data integrity with primary key or unique constraint implementing existential integrity. To enforce data integrity, column of one relation can have only those values available in primary key column of other relation. This is called foreign key implementing referential Integrity.
- The Relational Model is free from structural dependence. The access mechanism is not affected by any change in the relational data structure.
- The database designer can focus on logical structure of data rather than physical storage or access mechanism
- Easier database design, implementation and management
- Relational model enforces ad hoc query capability through Query Language
- It is a powerful and efficient model to represent database
- Substantial hardware and system software overhead
- Can facilitate poor design and implementation
- May promote “islands of information” problems