0% found this document useful (0 votes)
186 views41 pages

Lectuer-2 Database Design and Applications: BITS Pilani

The document provides details about database design concepts including the database design process, entity relationship (ER) modeling concepts, and an example database schema for a company. The major steps in database design are requirements analysis, conceptual design using ER modeling, logical design of tables and relationships, and physical design including indexing and storage. The example database tracks employees, departments, projects, and employee dependents, with entities like Employee, Department, Project, and Dependent. Relationships between these entities like works for, manages, controls are also described. Finally, an ER diagram of the sample company database is shown.

Uploaded by

amit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
186 views41 pages

Lectuer-2 Database Design and Applications: BITS Pilani

The document provides details about database design concepts including the database design process, entity relationship (ER) modeling concepts, and an example database schema for a company. The major steps in database design are requirements analysis, conceptual design using ER modeling, logical design of tables and relationships, and physical design including indexing and storage. The example database tracks employees, departments, projects, and employee dependents, with entities like Employee, Department, Project, and Dependent. Relationships between these entities like works for, manages, controls are also described. Finally, an ER diagram of the sample company database is shown.

Uploaded by

amit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Lectuer-2

Database Design and


Applications
BITS Pilani Ashish Narang
Pilani Campus
BITS Pilani
Pilani Campus

First Semester

2020-21
Contents

1. Steps in Database Design Process

2. ER Concepts (Entities, Attributes, Associations etc.)

3. ER Notations

4. Class Hierarchies

BITS Pilani, Pilani Campus


Major Steps in Database
Design Process
• Requirement Analysis
 Understanding the domain
 Identifying the data to be stored
 Identifying the constraints
• Conceptual Database design
 E-R modeling
• Logical Database Design
 Designing tables and relationships
• Refinement of schema
• Physical database design
 Indexing
 Storage formats

BITS Pilani, Pilani Campus


ER Model
• An E-R model is a detailed logical representation of the data for
an organization or for a business area. An ER model normally is
expressed as an Entity-Relationship diagram (ER diagram),
which is a graphical representation of an ER model.

• The basic components of an ER model are


 Entities

 Relationships

 Attributes

BITS Pilani, Pilani Campus


Entity
• Entity is an object in the real world that is distinguishable from
all other objects.

• Entity has independent existence.

• For Example, a particular person, car, house or employee.

BITS Pilani, Pilani Campus


Attributes
• Attributes are properties or characteristics possessed by an
entity.

• For example, Employee entity may be described by the


attributes Employee name, Age, Address, Salary and Job etc.

• A Particular entity will have value for each of its attributes.

BITS Pilani, Pilani Campus


Attributes Types
Several types of attributes occur in E-R Model
• Simple

• Composite

• Single valued

• Multi-valued

• Derived

BITS Pilani, Pilani Campus


Simple and Composite Attributes
• A simple attribute can not be divided into subparts.

• Simple attribute are also called atomic.

• A composite attribute can be subdivided into subparts which


represents more basic attributes with independent meaning.

• For Example, Address attribute of Employee Entity can be


divided into street_address, city, state and zip.

BITS Pilani, Pilani Campus


Single valued and Multi-valued
Attributes
• A single-valued attribute is the one will have only one value
for a given entity instance.
– For Example, Age is a single valued attribute

• A multi-valued attribute is the one which will have more than


one value for a given entity instance.
– For Example, Color attribute of a car

BITS Pilani, Pilani Campus


Derived Attributes
• A derived attribute is the one which is derived or calculated
from other related attributes.
• In Some cases, two attribute values are related.
For Example, Age and Birth_date attributes of a person.
• For a particular person entity, the value of age can be
determined from the current date and the value of that persons
birth date.
• Birth date is called as stored attribute.

BITS Pilani, Pilani Campus


Entity Types and Entity Sets
• An Entity type defines a collection of entities that have same
attributes. Each entity type in the database is described by its
name and attributes.

• The Collection of all the entities of a particular entity type in


the database at any point in time is called an entity set.

BITS Pilani, Pilani Campus


Contd..

BITS Pilani, Pilani Campus


Value Sets of Attributes
• Each simple attribute of an entity type is associated with a
value set, which specifies the set of values that may be
assigned to that attribute for each individual entity.

• For example, if the range of ages allowed for employees is


between 16 and 70, we can specify the value set of Age
attribute of Employee to be set of integer numbers between 16
and 70.

BITS Pilani, Pilani Campus


Weak Entity
• An entity whose existence depends on some other entity.

• The entity on which the weak entity depends is called the


identifying owner (or simply owner).

• A weak entity does not have its own identifier.

• Generally in an ER diagram a weak entity has an attribute that


serves as a partial identifier.

• The relationship between a weak entity and its owner is called


an identifying relationship.

BITS Pilani, Pilani Campus


Relationships
• A relationship represents an association between two or more
entities. An example of a relationship would be
– Employees are assigned to projects

– Department manage one or more projects

BITS Pilani, Pilani Campus


Notations Used in ER diagrams

BITS Pilani, Pilani Campus


Contd..

BITS Pilani, Pilani Campus


Contd..

BITS Pilani, Pilani Campus


Degree of a Relationship
• The degree of a relationship is the number of entities
associated with the relationship.
 Unary Relationship

 Binary Relationship

 Ternary Relationship

BITS Pilani, Pilani Campus


Cardinality of Relationship
• The cardinality ratio for a binary relationship specifies the
maximum number of relationship instances that an entity can
participate in.
 One to One

 One to Many

 Many to Many

BITS Pilani, Pilani Campus


Participation Constraint
• The participation constraint specifies whether the existence of
one entity depends on its being related to another entity via
relationship type.

• There are two types of participants constraints


 Total
 Partial

BITS Pilani, Pilani Campus


A Sample Database

• The COMPANY database keeps track of a company’s employees,


departments, and projects. Suppose that after the requirements
collection and analysis phase, the database designers provide the
following description of the miniworld—the part of the company
that will be represented in the database.
• The company is organized into departments. Each department has a
unique name, a unique number, and a particular employee who
manages the department. We keep track of the start date when that
employee began managing the department. A department may have
several locations.

BITS Pilani, Pilani Campus


Contd..

• A department controls a number of projects, each of which has a


unique name, a unique number, and a single location.
• We store each employee’s name, Social Security number, address,
salary, gender, and birth date. An employee is assigned to one
department, but may work on several projects, which are not
necessarily controlled by the same department. We keep track of the
number of hours per week that an employee works on each project.
We also keep track of the direct supervisor of each employee (who
is another employee).

BITS Pilani, Pilani Campus


Contd..

• We want to keep track of the dependents of each employee for


insurance purposes. We keep each dependent’s first name, gender,
birth date, and relationship to the employee.

BITS Pilani, Pilani Campus


Identify the Entities

1. Employee

2. Department

3. Project

4. Dependent

BITS Pilani, Pilani Campus


Contd..

BITS Pilani, Pilani Campus


Relationships

1. Employee manages Department

2. Employee works for Department

3. Department controls project

4. Employee supervises Employee

5. Employee works on projects

6. Employee has Dependents

BITS Pilani, Pilani Campus


Contd..

N 1

M N

BITS Pilani, Pilani Campus


Contd..

1 1

1 N

BITS Pilani, Pilani Campus


Contd..

1 N

Supervisee Supervisor

BITS Pilani, Pilani Campus


ER Diagram of Company
Database

BITS Pilani, Pilani Campus


University Management System

Consider a university with many departments. Each department has


unique D.no, D_name and location. A department can offer any
number of courses. Several professors work for a department. Each
Professor is given a unique code, name and contact number. Each
professor works for one department. Each department has one
professor as head. A Professor can head only one department and
can teach 2 to 4 courses. A student can enroll for any number of
courses. A course can be taught by multiple professors. Each course
has some credits associated with it and can have any number of
students. Each student has unique Rollno, Name and Address.

BITS Pilani, Pilani Campus


Identify the Entities

The different entities are

1. Department

2. Course

3. Professor

4. Student

BITS Pilani, Pilani Campus


Identify key Attributes

Following are the primary key attributes for each entity


• Dno(Department number) key attribute of Department

• C_code(Course Code) key attribute of Course

• Roll_no(Roll number) key attribute of Student

• P_code(Professor code) key attribute of Teacher

BITS Pilani, Pilani Campus


Identify other Relevant Attributes

• Department entity will have


• dname
• loc
• Course entity will have
• c_name
• credits
• Professor will have
• Name
• mob_no
• Student entity will have
• Name
• address

BITS Pilani, Pilani Campus


Identify Relationships

• Department Offers Courses

• Department has Professors

• Student Enroll for Courses

• Professors teach Courses

• Professor heads Department

BITS Pilani, Pilani Campus


Draw E-R Diagram

Dname loc C_code C_name


Dno credits

1 N
Department Offers Course

1 N
1 N

Teaches Enroll
has heads

1 M
N M
Professor Student

P_code name mob_no Roll_no Name Address

BITS Pilani, Pilani Campus


Class Hierarchies

BITS Pilani, Pilani Campus


Disjointness

BITS Pilani, Pilani Campus


Overlapping

BITS Pilani, Pilani Campus

You might also like