Showing posts with label DBMS. Show all posts
Showing posts with label DBMS. Show all posts

Wednesday 20 April 2022

ER [Entity–relationship] Model

ER Model is a popular high-level (conceptual) data model. It is an approach to designing Semantic Conceptual schema of a Database. ER model allows us to describe the data involved in a real-world environment in terms of objects and their relationships, which are widely used in design of database. ER model provides preliminary concepts or idea about the data representation which is later modified to achieve final detailed design.

Important concepts/notions used in ER modeling are-

Entity 

It is an object in real-world or some idea or concept which can be distinguished from other objects.

Ex.: person, school, class, department, weather, salary, temperature etc.

Entity has independent existence. 

Entity type

Each entity belongs to an Entity type that defines the structure.

Entity Set 

It is a Collection of similar objects.

Attribute

Reflects a property of an object or entity. We have following types of attributes.

> Simple attribute

> Composite attribute

> Single valued attribute

> Multi-valued attribute

> Derived attribute

> Stored attribute

Key

Is an Attribute of an entity type whose value can uniquely identify an entity in a set.

Relationship

The association between entities is known as relationship.

Domain of an attribute

The set of possible values is known as domain of an attribute



Degree of a Relationship

Degree is the number of entity type participate in a relationship. 
If there are two entity types involved it is a binary relationship type
eg: Manager manages employee

If there are three entity types involved it is a ternary relationship type  

Cardinality of a relationship

Relationships are rarely one-to-one. 
For example, a manager usually manages more than one employee. This is described by the cardinality of the relationship, for which there are four possible categories. 



Data Model

Data Model is a collection of concepts that can be used to describe the structure of the database. Structure means data types, relationships, constraints etc. DBMS allows a user to define the data to be stored in terms of a data model. 

1.  High-level data models 

2.  Low-level data models

3. Representational or Implementation data models 

High-level Data Models

Use set of concepts to describe the database, where the descriptions are close to user views. High-level data models are also known as conceptual models. In conceptual data modeling we use concepts like – entity, attributes, relationship etc. 

Low-level Data Models

Give details about how the data is stored in a computers (storage level details).

Representational/Implementation Data Models

This is in between high-level and low-level data models. Here we represent the concepts described in conceptual model using a specific structures like, networks, objects, tables, trees etc. Ex: Relational Model, NW Model, Hierarchical Model, Object Model, Object relational model etc. 

Relational Model

The central data description construct in this model is a relation, which can be thought of as a set of records. 

Schema

Description of data in terms of a data model is called a schema. A relation schema specifies the name of the relation, fields, type etc. 

eg:. Student (sid: string; name: string; age: integer) every row follows the schema of the relation.

The following are some important representational data models (DBMS Specific) 

1. Network Model

Though the basic structure is a record, the relationships are captured using links. The database can be seen as an arbitrary network of records connected by links. Ex.: GE’s Integrated Data store (IDS), in Early 1960s 

2. Hierarchical Model 

The records containing data are organized as a collection of trees. Ex.: IBMs IMS (Information Management System), in late 1960s 

3. Relational Model (early 1970s)

Data & relationships are captured as tables & keys. Ex.: Oracle, IBMs DB2, MySQL, Informix, Sybase, MS Access, Ingress, MySQL etc. The basic storage structure is a record. 

4. Object Data Model

Objects created through object–oriented programs can be stored in database. Ex.: Object Store 

5. Object Relational Model

Objects can be stores in tables. Ex.: Oracle, Informix 

Database Schema

Description of a database is called as database Schema.

Three-Schema Architecture:

A database can be described using three different levels of abstractions. Description at each level can be defined by a schema. For each abstraction we focus on one of the specific issues such as user views, concepts, storage etc. 

1. External schema: Used to describe the database at external level. Also described in terms of the data model of that DBMS. This allows data access to be customized at the level of individual users/groups/applications. Any external schema has one or more views and relations from the conceptual schema. This schema design is guided by end user requirements. 

2. Conceptual schema (logical schema) Describes the stored data in terms of the data model specific to that DBMS. In RDBMS conceptual schema describes all relations that are stored in the database. Arriving at good choice of relations, fields and constraints is known as conceptual database design. 

3. Physical schema: Describes the physical storage strategy for the database.