Practical 1
Practical 1
ER model
o ER model stands for an Entity-Relationship model. It is a high-level data model. This model is
used to define the data elements and relationship for a specified system.
o It develops a conceptual design for the database. It also develops a very simple and easy to
design view of data.
o In ER modeling, the database structure is portrayed as a diagram called an entity-relationship
diagram.
Component of ER Diagram
1. Entity:
o An entity may be any object, class, person or place. In the ER diagram, an entity can be
represented as rectangles.
o Consider an organization as an example- manager, product, employee, department etc. can be
taken as an entity.
a. Weak Entity
o An entity that depends on another entity called a weak entity. The weak entity doesn't contain
any key attribute of its own. The weak entity is represented by a double rectangle.
o
2. Attribute
o The attribute is used to describe the property of an entity. Eclipse is used to represent an
attribute.
o For example, id, age, contact number, name, etc. can be attributes of a student.
a. Key Attribute
o The key attribute is used to represent the main characteristics of an entity. It represents a
primary key. The key attribute is represented by an ellipse with the text underlined.
b. Composite Attribute
o An attribute that composed of many other attributes is known as a composite attribute. The
composite attribute is represented by an ellipse, and those ellipses are connected with an
ellipse.
o
c. Multivalued Attribute
o An attribute can have more than one value. These attributes are known as a multivalued
attribute. The double oval is used to represent multivalued attribute.
o For example, a student can have more than one phone number.
d. Derived Attribute
o An attribute that can be derived from other attribute is known as a derived attribute. It can be
represented by a dashed ellipse.
o For example, A person's age changes over time and can be derived from another attribute like
Date of birth.
3. Relationship
o A relationship is used to describe the relation between entities. Diamond or rhombus is used to
represent the relationship.
b. One-to-many relationship
o When only one instance of the entity on the left, and more than one instance of an entity on the
right associates with the relationship then this is known as a one-to-many relationship.
o For example, Scientist can invent many inventions, but the invention is done by the only specific
scientist.
c. Many-to-one relationship
o When more than one instance of the entity on the left, and only one instance of an entity on the
right associates with the relationship then it is known as a many-to-one relationship.
o For example, Student enrolls for only one course, but a course can have many students.
d. Many-to-many relationship
o When more than one instance of the entity on the left, and more than one instance of an entity
on the right associates with the relationship then it is known as a many-to-many relationship.
o For example, Employee can assign by many projects and project can have many employees.
2. COMPANY DATABASE:
EMPLOYEE (SSN, Name, Address, Sex, Salary, SuperSSN, DNo)
DEPARTMENT (DNo, DName, MgrSSN, MgrStartDate)
DLOCATION (DNo,DLoc)
PROJECT (PNo, PName, PLocation, DNo)
WORKS_ON (SSN, PNo, Hours)
3. Bank Database:
Bank (IFSC code, Name, telephone , Address)
Staff (ID, Name, Address, Phone, Salary, Age)
User (Account number, Name, Address, Phone, Balance, DOB, aadhar number, Account type,
Opening date)
4. College Database:
College (RegNo, Address, Name)
Office_Staff (ID, Name, Gender, Address)
Teaching_staff (ID, Name, Gender, Address)
Student (PRN, Name, Age, Address, Gender)
Books (BookID, Name, Author)
Course (Year, Subjects)
Marks (PRN, Test1, Test2, Final)
ER-Diagram:
1. Student database ER diagram
2. Company Database ER diagram
3. Bank Database:
4. College Database:
Schema :
1. Comapany
Employee
Department
DNO DLOC
Project
Work on
2. Student:
Student
PRN Name Address Gender
Semester
SSID Semester Section
Class
PRN SSID
Subject
SubjectCode Title Semester Credits
Marks
PRN SubjectCode Test1 Test2 Final
3. Bank
Bank
IFSC Code Name Address Telephone
Staff
ID Name Salary Telephone Address Age
User
AccountNo Name Address Telephon AdharNo AccountType DOB Balance
e
4. College
College
RegNo Name Address Telephone
Office_Staff
ID Name Address Gender
Teaching_Staff
ID Name Address Gender
Student
PRN Name Address Telephone Age
Books
BookID Name Author
Course
Year Subjects
Conclusion:
In this practical we learned about various attributes and the components of ER diagram. We drew ER
diagrams for college, student, company and bank.
Questions:
1. What is an ER Diagram?
An ER diagram is a graphical representation of an entity relationship model. It is used to
represent the relationships between entities in a database.
3. Why are composite keys important when modeling databases with entity-relationship
diagrams?
Composite keys are important when modeling databases with entity-relationship diagrams
because they can help to uniquely identify each row in a table. This is especially important
when modeling databases that will be used for transactional purposes, such as online stores.
By using a composite key, you can ensure that each row in the database is uniquely identified,
which can help to prevent errors during transactions.
5. What is normalization?
Normalization is the process of organizing data in a database so that it meets certain
requirements, in order to reduce data redundancy and improve data integrity.