Database Models?
In this article we are going to look at the different database models.
Whether you use Microsoft Access or a more complex database tool, you are interacting with database models. The purpose of a data model is to organize and standardize data elements with how they are related to other data elements. There are several types of database models, each of which is best for a particular use case. The common database models are Entity-Relationship, Hierarchical, Network, Relational, Object-Oriented Database, and Object-Relational. We will look at the details of each data model type. To help illustrate the definitions of each data model type we will use cars in our example.
Entity Relationship Model - This model has entities that have one or more relationships between other entities. The entities can be part of sets like a set of entities or set of relationships that use general attributes and constraints. You can think of entity relationships in terms of primary and foreign keys. So, using the example of the car, we can create a database called automobile with a table in the database called cars. Then in the cars table, there are specific attributes listed in data columns such as, make, model, year, color, and the number of doors. Because these attributes are fixed each car is described in an identical way. Then we have tables for each column make, model, year, color, and the number of doors. So instead of storing an actual value in the cars table, we store a key in the cars table column to a corresponding attribute table column. With a populated data table, we can have entity sets (same attributes of identical value) such as cars with the same number of doors or the same color. This provides relationships between the entities.
Hierarchical Model – This is a one-to-many relationship or can also describe this model as Parent nodes with Children nodes. Each parent row can have a reference to many child rows in a different database table(s). Think of a car manufacturer as the parent node, and the different cars it produces are child nodes. Using our automobile database, we can add a manufacturer table. Toyota makes 3 different sedan cars, Avalon, Camry, and Corolla, each has doors and comes in distinct colors. Toyota is the parent node, and each car (Avalon, Camry, and Corolla) is a child node. Toyota has a one-to-many relationship with the cars it manufactures. So, there would be a column in the cars table that stores the manufacturer attribute.
Network Model – This is a one-to-many relationship or can also describe this model as Parent nodes with Children nodes. Each parent row can have a reference to many child rows in a different database table(s). Think of a car manufacturer as the parent node, and the different cars it produces are child nodes. Using our automobile database, we can add a manufacturer table. Toyota makes 3 different sedan cars, Avalon, Camry, and Corolla, each has doors and comes in different colors. Toyota is the parent node, and each car (Avalon, Camry, and Corolla) is a child node. Toyota has a one-to-many relationship with the cars it manufactures. So, there would be a column in the cars table that references the manufacturer's table.
Relational Model – This is the most popular model since it is the foundation for Relational Databases. Data points are stored in tables that have columns and rows. With this structure, we have a declarative way to access the data using Structured Query Language (SQL). So, you have a database called automobile and inside the database, there is a table called cars which has the columns make, model, year, color, and the number of doors. Each car is a row in the table. Since we know this structure, it is easy to write a query statement that scans the table for the cars we are interested in.
Object-Oriented Model – This model uses object collections and does not store data in a constrained or uniform manner. The data schema can be dynamically changed and the data in this model have related features and methods. So, unlike the other models above, cars are viewed as objects not necessarily stored in tables made up of attributes and entities. You look at make, model, year, color, and the number of doors as features of a car object. So, using the example of an automobile database entries would have car objects which store some or all the attributes.
Object-Relational Model - This model uses a combination of the Object-Oriented model and the Relational Model. This is where the flexibility of an Object-Oriented data model implements the declarative language of the relational model. Let us use the automobile database example, in the relational model we used tables to store cars in rows. With Object-Relational cars are objects and where the car’s attribute is the same as other cars becomes an object collection that can be queried. So instead of a query referencing a table, it uses an object collection instead. If we wanted to get a list of all red cars a user-defined, or dynamic data type could be defined to form a collection of cars with a red color attribute then a declarative query statement would be run to produce the list.
Conclusion
We examined common database models and found that models are important when designing a database solution. When comparing a project's requirements to database models, it makes a correlation to what type of database technology needs to be used. Not being familiar with database models can be a costly mistake. Let Explait help with identifying the correct model and underlying data management solution.