01 - Data Models

A database is a collection of logically related data. Data are the values that can be recorded. User can record the data in an indexed address book or on an hard disk through the software Microsoft Excel or Microsoft Access.

Database Management is the task of maintaining databases so that the information is available easily. The software performs the task of database management is called database management system (DBMS). They are designed to maintain large data.

The main objectives of DBMS are as follows:

1) Provide an efficient and easy way to store, update and retrieve data from a database.

2) Manage information about users who interact with the DBMS and the tasks that the users can perform on data

1.1 Object Oriented Model

There are various models as object oriented, entity relationship, object oriented and binary model. The most common and widely used is the ER model. It is the most ideal data model for the database design. The model was introduced in 1976 by Peter Chan.

The ER Model

The model is a collection of objects and entities and the relationship among them. The diagram technique for the model is as shown below:

In the above diagram, COURSE and SEMESTER are two entities. The COURSE entity contains two attributes as Title and Code. The SEMESTER entity contains three attributes as Start Date, End Date, and Sem no. The TAUGHT relationship is achieved between the two entities.

Entities

An entity is any object, person or activity about which the data is recorded. An entity can be categorized as entity type and entity instance. An entity type is a set of things that share common properties. An entity instance is an individual occurrence of an entity type.

In an ER Model, entity is represented inside a box. They are represented in uppercase in the ER Model. There are two types of entities as dependent an independent. An entity which depends on another entity is known as dependent entity. An entity that does not depend on any entity for existence is known as independent entity. Dependent entities are also known as weak entities and independent entities are called as regular entities.

Consider an example of an entity type, OFFERING that refers to the combinations of subjects in a course. A course with the same name can be offered in different semesters at different universities. The existence depends on the entity type COURSE.

The existence of the entity B is dependent on entity A when:

· Some instance of A must exist before B can exist

· B will not exist if A doe not exist

The following diagram consists of an entity, OFFERING which is dependent on entity COURSE.

In the above diagram, COURSE is as independent entity.

Relationship

A relationship is a type of association of entity types. A relationship is shown by a diamond with the name of the relationship type. The following diagram consists of two entities as TEACHER and STUDENT that are associated with the relationship TEACH.

A relationship can associate an entity with itself. For example, a teacher can teach in a university may marry another teacher. The following diagram represents the association of an entity with itself.

Multiple relationships can also exist between the same entities. The following diagram represents the multiple relationships between the entities, TEACHER and STUDENT.

In the above diagram, TEACHER entity shares many relationships with the STUDENT entity. A teacher can teach, manage and evaluate the students.

Types of relationships

There are following types of relationships.

· One to One relationship

· One to Many relationship

· Many to Many relationship

Consider an example of university. For a DEPARTMENT there can be only one DEPARTMENT HEAD. The following diagram shows one to one relationship between DEPARTMENT and DEPARTMENT HEAD.

A STUDENT can MAJOR only in one course, but many STUDENTs can register for the MAJOR course. This is an example of many to one relationship. The following diagram shows the many to one relationship between them.

A STUDENT can take many COURSEs and many STUDENTs can register for a given COURSE. This is an example of many to many relationships The following diagram represents the many to many relationship.

Attributes

An attribute is a property of a given entity. The attributes has instances, An attribute instance is an individual occurrence of an attribute. For example, roll number 101 is the instance of the attribute, ROLL_NO.

An attribute instance is also a particular property of an individual instance. Attributes are depicted as ellipses labeled with the name of the property. The key property is underlined. A key property uniquely identifies an entity instance.

The following figure shows the various attributes of an entity, STUDENT.

Subtypes and SuperTypes

A subtype is a subset of another entity. For example consider an entity COURSE. There are two types of COURSES as semester courses and standalone courses. The entity COURSE is supertype and SEMESTER and STANDALONE are subtypes. There are some other attributes as name, content, duration and semester no.

The following diagram shows the relationship between supertype and subtypes.

1.2 Record Based logical Model

There are other data models available in the database. The three types of record based logical models are as follows:

1) Hierarchical model: In this model, data is represented in the form of a tree, and the relationship between data is represented by links.

2) Network model: In this model, the data and relationships among them are represented in the form of records and links. It is similar to the hierarchical model but the records in a database are generated graphically.

3) Relational model: In this model, the table in a database has a fixed length record with fixed number of attributes and fields. This model is widely used by the users in developing the database.

1.3 Relational Model

The relational model is used to simplify the database structure. It was developed by Dr E.F.Codd. It represents the data in the database as tables in the row column format. The following table describes the details of a teacher.

T_CODE

NAME

AGE

SEMESTER

101

Nancy

25

I

102

Sam

26

II

103

Mac

30

IV

104

Joe

32

III

An RDBMS can be defined as a database management system where all the data is visible to the user is placed as tables of data values, and all the database operations work on these tables.

The basic of the relational database is a tabular arrangement of data values. Each table has a unique table name that identifies the contents. The row in the table is called as tuple and the column is called as an attribute. Every column in the table must have a unique name. The number of tuples is called as cardinality and the number of attributes is called as the degree of the table.

Each attribute of a table is associated with a domain. A domain is the collection of values from which one or more attributes contain actual values. The domain lists the possible values for an attribute. The domain of the CODE attribute would be set to the supplier codes.

The following diagram describes the data structure of the RDBMS.

Like us on Facebook