Professional Documents
Culture Documents
Data Model
A data model refers to the logical inter-relationships and data flow between different data elements
involved. It also documents the way data is stored and retrieved.
Every database and database management system is based on particular database model. Data
model consists of set of rules and standards that define how the data is organized in a database. A
data model also provides a set of operation for manipulation of the data stored in the database.
Course_Table :
The most widely used conceptual model is entity relationship (E-R) model. The conceptual
model represents the global view of data.
Relationship
A relationship is a situation that exists between two relational database tables when one table has a
foreign key that references the primary key of the other table.
Cardinality
Cardinality defines the numerical attributes of the relationship between two entities or entity
sets. The three main cardinal relationships are one-to-one, one-to-many, and many-many.
✗ A one-to-one example would be one student associated with one mailing address.
Advantage of ER model
1. Easy and simple to understand with minimal training.
2. It is possible to find connection from one node to all other nodes.
3. It has explicit(dedicated) linkages of entities.
Disadvantages of ER model
1. Limited relationship representation.
2. No representation of data manipulation.
Q. How Degree of Relation and Cardinality of a Relation are different?
Degree of a Relation - is the number of attributes in a relation (number of columns)
Cardinality of a Relation - is the number of tuples in a relation (number of rows)
Examples
General Idea
Step 1: Identify the entities
Step 2: Find the relationship between the entities
Step 3: Identify the attributes for each entity.
Step 4: Draw ERD with the information
- Aggregration:
Aggregration is a process when relation between two entities is treated as a single
entity.
In the diagram above, the relationship between Center and Course together, is acting
as an Entity, which is in relationship with another entity Visitor.
Keys
A key is an important constraint which is a group of one or more attributes that uniquely identify an
entity in the entity set.
1. Primary Key – A primary is a column or set of columns in a table that uniquely identifies
tuples (rows) in that table.
In the above Student table, the Stu_Id column uniquely identifies each row of the table.
Note:
• We denote the primary key by underlining the column name.
• The value of primary key should be unique for each row of the table. Primary key
column cannot contain duplicate values.
• Primary key column should not contain nulls.
• Primary keys are not necessarily to be a single column; more than one column can
also be a primary key for a table.
For e.g. {Stu_Id, Stu_Name} collectively can play a role of primary key in the above
table
2. Super Key – A super key is a set of one of more columns (attributes) to uniquely identify
rows in a table.
E.g. for entity set “Student”={roll no, class, name, address, dob, year}
Some of super keys are {roll no, class, name, address}, {roll no, class, Address, dob}, {roll
no, class, name, dob, year} etc.
3. Candidate Key – A super key with no redundant attribute is known as candidate key.
Basic Rules:
1. Representation of Entity Sets Tables
All the entities represented in the rectangular box in the ER diagram become independent
tables in the database
- Representation of Strong Entity Sets with Simple Attributes
Customer(ID, First Name, Middle Name, Last Name, City, State, House Number, DOB)
Customer_Phone(ID, Phone Number)
job(title, level)
employee(employee_id, employee_name)
branch(branch_name, branch_city, assets)
works_on(employee_id, branch_name, title)
UPS prides itself on having up-to-date information on the processing and current location of
each shipped item. To do this, UPS relies on a company-wide information system. Shipped
items are the heart of the UPS product tracking information system. Shipped items can be
characterized by item number (unique), weight, dimensions, insurance amount, destination,
and final delivery date. Shipped items are received into the UPS system at a single retail
center. Retail centers are characterized by their type, uniqueID, and address. Shipped items
make their way to their destination via one or more standard UPS transportation events (i.e.,
flights, truck deliveries). These transportation events are characterized by a unique
scheduleNumber, a type (e.g, flight, truck), and a deliveryRoute.
Please create an Entity Relationship diagram that captures this information about the UPS
system.
Soln:
• Upper section: Contains the name of the class. This section is always required, whether you
are talking about the classifier or an object.
• Middle section: Contains the attributes of the class. Use this section to describe the qualities
of the class. This is only required when describing a specific instance of a class.
• Bottom section: Includes class operations (methods). Displayed in list format, each
operation takes up its own line. The operations describe how a class interacts with data.
✗ Association
(owners feed pets, pets please owners (association))
If two classes in a model need to communicate with each other, there must be link between
them, and that can be represented by an association (connector).
Association can be represented by a line between these classes with an arrow indicating
the navigation direction. In case arrow is on the both sides, association has bidirectional
association.
✗ Aggregation
Aggregation implies a relationship where the child can exist independently of the parent.
Example: Class (parent) and Student (child). Delete the Class and the Students still exist
✗ Composition
Composition implies a relationship where the child cannot exist independent of the parent.
Example: House (parent) and Room (child). Rooms don't exist separate to a House
Q. Consider a store with multiple branches and a system generates reports for each branch monthly
and annually and an overall report as well monthly and annually. So in total there are 4 types of
reports
1. Monthly branch-wise report
2. Monthly overall report
3. Annual branch-wise report
4. Annual overall report
How are they to be depicted in a class diagram?