Dbms Exp 1 Theory
Dbms Exp 1 Theory
Group A
Assignment No 1
Outcome: Design E-R Model for given requirements and convert the same into
database tables
Theory:
• Entity-Relationship model is used in the conceptual design of a database (conceptual
level, conceptual schema)
• A database schema in the ER model can be represented pictorially (Entity-Relationship
diagram)
Types of entities:
1. Strong Entity
The strong entity has a primary key. Weak entities are dependent on strong entity. Its existence
is not dependent on any other entity. It is represented by rectangle.
E.g.
2. Weak Entity
The weak entity in DBMS do not have a primary key and are dependent on the other strong
entity. It is represented by double rectangle.
E.g.
• Entity Set:
Collection of entities of a particular entity type at any point in time; entity set is typically
referred to using the same name as entity type.
• Attributes:
An entity is represented by a set of attributes (its descriptive properties), e.g., name, age,
salary, price etc.
Attribute values that describe each entity become a major part of the data eventually stored
in a database.
With each attribute a domain is associated, i.e., a set of permitted values for an attribute.
Possible domains are integer, string, dates, etc.
Types of Attributes:
i. Simple attribute
Simple attributes are atomic values, which cannot be divided further. For example, a
student's phone number is an atomic value of 10 digits.
E.g.,
Mobile No
ii. Composite
Composite attributes are made of more than one simple attribute.
E.g., a student's complete name may have first_name, middle_name and last_name.
iv. Multi-valued
An attribute which has many values. It represented by double oval.
E.g., Mobile No, Email Id
v. Derived
An attribute which can derive its value from another attribute. It represented by dashed
oval.
E.g.,
ID
• Relationship:
It is association among two or more entities, e.g., “customer ‘Smith’ orders product
’PC42’”
• Constraint:
Mapping Constraint-
From one entity set how many entities are associated with other entity sets through
relationship set.
1) Many-To-Many (default)
Meaning: An employee can work in many departments (≥ 0),and a department can have
several employees
2) Many-To-One
Meaning: An employee can work in at most one department (≤ 1), and a department can
have several employees.
3) One-To-Many
Meaning: An employee can work in many departments (≥ 0),but a department can have
at most one employee.
4) One-To-One
Meaning: An employee can work in at most one department, and a department can have
at most one employee.
• Participation constraint:
It specifies the presence of an entity when it is related to another entity in a relationship
type. It is also called the minimum cardinality constraint.
This constraint specifies the number of instances of an entity that are participating in the
relationship type.
University database
The university database stores details about university students, courses, the semester a
student took a particular course (and his mark and grade if he completed it), and what degree
program each student is enrolled in.
• Student is a strong entity, with an identifier, student_id, created to be the primary key
used to distinguish between students.
• Program is a strong entity, with the identifier program_id as the primary key used to
distinguish between programs.
• Each student must be enrolled in a program, so the Student entity participates totally
in the many-to-one EnrollsIn relationship with Program. A program can exist without
having any enrolled students, so it participates partially in this relationship.
• A Course has meaning only in the context of a Program, so it’s a weak entity,
with course_id as a weak key. This means that a Course is uniquely identified using
its course_id and the program_id of its owning program.
• As a weak entity, Course participates totally in the many-to-one identifying
relationship with its owning Program. This relationship
has Year and Semester attributes that identify its sequence position.
• Student and Course are related through the many-to-many Attempts relationships; a
course can exist without a student, and a student can be enrolled without attempting
any courses, so the participation is not total.
• When a student attempts a course, there are attributes to capture the Year and Semester, and
the Mark and Grade.
o ERD plus
• Web-based database modeling tool that offers relational schemas, SQL generation,
data export, ER diagram conversion, and more.Designed for business analysts, a
database modeling tool that helps with drawing entity relationship diagram
components, converting ER Diagrams to relational schemas, exporting SQL, and
more.
• The notation supports drawing regular and weak entities, various types of attributes
(regular, unique, multi-valued, derived, composite, and optional), and all possible
cardinality constraints of relationships (mandatory-many, optional-many, mandatory-
one and optional-one).
❖ Normalization
Database Normalization is a technique of organizing the data in the database.
Normalization is a systematic approach of decomposing tables to eliminate data
redundancy(repetition) and undesirable characteristics like Insertion, Update and
Deletion Anomalies. It is a multi-step process that puts data into tabular form,
removing duplicated data from the relation tables.
Normalization is used for mainly two purposes,
• Eliminating redundant(useless) data.
• Ensuring data dependencies make sense i.e., data is logically stored.
<ProjectInfo>
ProjectID ProjectName
P09 Geo Location
P07 Cluster Exploration
P03 IoT Devices
P05 Cloud Deployment
Example: Let’s say a company wants to store the complete address of each employee, they
create a table named Employee_Details that looks like this:
Emp_Id Emp_Name Emp_Zip Emp_State Emp_City Emp_District
1001 John 282005 UP Agra Dayal Bagh
1002 Ajeet 222008 TN Chennai M-City
1006 Lora 282007 TN Chennai Urrapakkam
1101 Lilly 292008 UK Pauri Bhagwan
1201 Steve 222999 MP Gwalior Ratan
Employee Table:
Emp_Id Emp_Name Emp_Zip
1001 John 282005
1002 Ajeet 222008
1006 Lora 282007
1101 Lilly 292008
1201 Steve 222999
Employee_Zip table:
Emp_Zip Emp_State Emp_City Emp_District
282005 UP Agra Dayal Bagh
222008 TN Chennai M-City
282007 TN Chennai Urrapakkam
292008 UK Pauri Bhagwan
222999 MP Gwalior Ratan
Example: Suppose there is a company wherein employees work in more than one department. They
store the data like this:
EMPLOYEE table:
Emp_Id Emp_Nationality Emp_Dept Dept_Type Dept_No_Of_Emp
1001 Austrian Production and planning D001 200
1001 Austrian stores D001 250
1002 American design and technical support D134 100
1002 American Purchasing department D134 600
The table is not in BCNF because neither EMP_DEPT nor EMP_ID alone are keys.
To convert the given table into BCNF, we decompose it into three tables:
EMP_COUNTRY table:
EMP_ID EMP_COUNTRY
264 India
264 India
EMP_DEPT table:
EMP_DEPT DEPT_TYPE EMP_DEPT_NO
Designing D394 283
Testing D394 300
Stores D283 232
Developing D283 549
EMP_DEPT_MAPPING table:
EMP_ID EMP_DEPT
D394 283
D394 300
D283 232
D283 549
Functional dependencies:
EMP_ID → EMP_COUNTRY
EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
Candidate keys:
For the first table: EMP_ID
For the second table: EMP_DEPT
For the third table: {EMP_ID, EMP_DEPT}
Viva Questions:
• What is database?
• What is ER modeling?
• Explain the attribute and its types?
• What is entity?
• Draw ER diagram for student database system?
Date:
Marks obtained:
Sign of course coordinator:
Name of course Coordinator: