Web and Database Technology-II (MCS-343L) SSUET/QR/114
Laboratory Exercise 04
Objective:
Follow instructions to use Erwin, a data modeling tool.
Theory:
4.1 Data Models
Data models define how the logical structure of a database is modeled. Data Models are
fundamental entities to introduce abstraction in a DBMS. Data models define how data is
connected to each other and how they are processed and stored inside the system.
A data model can be thought of as a flowchart that illustrates data entities, their attributes and
the relationships between entities. It enables data management and analytics teams to document
data requirements for applications and identify errors in development plans before any code is
written.
4.2 Three Levels of Data Abstraction
There are many types of data models, with different types of possible layouts. The data
processing community identifies three kinds of modeling to represent levels of thought as the
models are developed.
4.2.1 Conceptual data model
This is the “big picture” model that represents the overall structure and content but not
the detail of the data plan. It is the typical starting point for data modeling, identifying
the various data sets and data flow through the organization. The conceptual model is
the high-level blueprint for development of the logical and physical models and is an
important part of the data architecture documentation.
4.2.2 Logical data model
The second level of detail is the logical data model. It most closely relates to the general
definition of “data model” in that it describes the data flow and database content. The
logical model adds detail to the overall structure in the conceptual model but does not
include specifications for the database itself as the model can be applied to various
database technologies and products. (Note that there may not be a conceptual model if
the project relates to a single application or other limited system.)
4.2.3 Physical data model
The physical database model describes the specifics of how the logical model will be
realized. It must contain enough detail to enable technologists to create the actual
database structure in hardware and software to support the applications that will use it.
Needless to say, the physical data model is specific to a designated database software
system. There can be multiple physical models derived from a single logical model if
different database systems will be used.
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 25
Web and Database Technology-II (MCS-343L) SSUET/QR/114
4.3 Data Modeling
Data modeling is the process of creating a simplified diagram of a software system and the data
elements it contains, using text and symbols to represent the data and how it flows. Data models
provide a blueprint for designing a new database or reengineering a legacy application. Overall,
data modeling helps an organization use its data effectively to meet business needs for
information.
4.3.1 Importance of Data Modelling
A comprehensive and optimized data model helps create a simplified, logical database that
eliminates redundancy, reduces storage requirements, and enables efficient retrieval. It also
equips all systems with a ‘single source of truth’ – which is essential for effective operations
and provable compliance with regulations and regulatory requirements.
4.3.2 Types of Data Modeling
The three primary data model types are relational, dimensional, and entity-relationship (E-R).
There are also several others that are not in general use, including hierarchical, network, object-
oriented, and multi-value. The model type defines the logical structure – how the data is stored,
logically – and therefore how it is stored, organized, and retrieved.
4.3.2.1 Relational: Although “older” in approach, the most common database model
still in use today is relational, which stores the data in fixed-format records and arranges
data in tables with rows and columns.
Basic terminology used in relational database design includes “relations” (the table with
rows and columns), “attributes” (columns), “tuples” (rows), and “domain” (set of
values allowed in a column). While there are additional terms and structural
requirements that define a relational database, the important factor is the relationships
defined within that structure. Common data elements (or keys) link tables and data sets
together. Tables can also be related explicitly, like parent and child relationships
including one-to-one, one-to-many, or many-to-many.
4.3.2.2 Dimensional: Less rigid and structured, the dimensional approach favors a
contextual data structure that is more related to the business use or context. This
database structure is optimized for online queries and data warehousing tools. Critical
data elements, like a transaction quantity for example, are called “facts” and are
accompanied by reference information called “dimensions,” be that product ID, unit
price, or transaction date. A fact table is a primary table in a dimensional model.
Retrieval can be quick and efficient – with data for a specific type of activity stored
together – but the lack of relationship links can complicate analytical retrieval and use
of the data. Since the data structure is tied to the business function that produces and
uses the data, combining data produced by dissimilar systems (in a data warehouse, for
instance) can be problematic.
4.3.2.3 Entity-Relationship (E-R): Entity-Relationship (ER) Model is based on the
notion of real-world entities and relationships among them. While formulating real-
world scenario into the database model, the ER Model creates entity set, relationship
set, general attributes and constraints. ER Model is best used for the conceptual design
of a database. ER Model is based on:
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 26
Web and Database Technology-II (MCS-343L) SSUET/QR/114
Entities and their attributes.
Relationships among entities.
Entity: An entity in an ER Model is a real-world entity having properties called
attributes. Every attribute is defined by its set of values called domain. For example, in
a school database, a student is considered as an entity. Student has various attributes
like name, age, class, etc.
Relationship: The logical association among entities is called relationship.
Relationships are mapped with entities in various ways.
Mapping cardinalities: Mapping cardinalities define the number of association
between two entities.
1. one to one: One entity from entity set A can be associated with at most one entity of
entity set B and vice versa.
2. one to many: One entity from entity set A can be associated with more than one
entities of entity set B however an entity from entity set B, can be associated with
at most one entity.
3. many to one: More than one entities from entity set A can be associated with at
most one entity of entity set B, however an entity from entity set B can be associated
with more than one entity from entity set A.
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 27
Web and Database Technology-II (MCS-343L) SSUET/QR/114
4. many to many: One entity from A can be associated with more than one entity
from B and vice versa.
ER Diagram Representation:
Entity
Entities are represented by means of rectangles. Rectangles are named with the entity
set they represent.
Attributes
Attributes are the properties of entities. Attributes are represented by means of ellipses.
Every ellipse represents one attribute and is directly connected to its entity (rectangle).
Composite Attributes
If the attributes are composite, they are further divided in a tree like structure. Every
node is then connected to its attribute. That is, composite attributes are represented by
ellipses that are connected with an ellipse.
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 28
Web and Database Technology-II (MCS-343L) SSUET/QR/114
Multivalued attributes
Multivalued Attributes are depicted by double ellipse.
Derived Attributes
Derived attributes are depicted by dashed ellipse.
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 29
Web and Database Technology-II (MCS-343L) SSUET/QR/114
Participation Constraints
Total Participation: Each entity is involved in the relationship. Total participation is
represented by double lines.
Partial participation: Not all entities are involved in the relationship. Partial participation is
represented by single lines.
4.4 Data Modeling and Database Design Using Erwin
A leading tool that makes Database Engineers to enter their Entity Relationship (ER) diagrams
in a graphical method and generate physical database strategies for common relational database
management systems such as Microsoft SQL Server and Oracle is ERwin.
ERwin supports a pattern of features of database strategy, which includes modeling the data,
forward engineering (It is the process of formation of a database schema and physical database
on the basis of a data model), and reverse engineering (It is the process of formation of a data
model on the basis of an available database) for a wide-ranging varieties of relational DBMS,
including Oracle, Microsoft Access, Sybase, DB2, and many more.
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 30
Web and Database Technology-II (MCS-343L) SSUET/QR/114
Starting with ERwin:
The upper portion of the workspace consists of Menu and Toolbars. The middle portion of the
workspace consists of two panes: the model explorer panel and the diagram window. The lower
portion contains two windows: first is the action log that shows a log of all alterations made to
the data model under design, and second is the advisories panel that shows messages related to
actions executed on the data model under design.
There are three model types supported by ERwin which is used by a Database Developer:
Logical: It is a theoretical model that contains entities, attributes, and relationships. This model
type is principally at the ER modeling level.
Physical: It is a database-specific model that comprises columns, relational tables, and their
associated data types.
Logical/Physical: It is a single model that contains both theoretical-level objects and physical-
level tables.
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 31
Web and Database Technology-II (MCS-343L) SSUET/QR/114
Adding Entity Types
If you want to add an entity type to the database design, either right-click on the ‘Entities’ entry
in the model explorer window and select ‘New’ or select the ‘Entity’ icon in the Menus and
Toolbars section of the workspace and click on the diagram window panel.
Adding Relationships
ERwin supports three types of relationships,
many-to-many
identifying,
non-identifying
ERwin categorizes the child entity type in a classifying relationship as ‘weak.’ To add a
relationship, in the model explorer window, right-click on the ‘Relationships’ entry and select
‘New.’ This will help in creating a new relationship.
Forward Engineering
ERwin offers a dominant feature called forward engineering that permits Database Developers
to transform the ER design into a schema generation SQL script for one or more target
relational databases. The resulting SQL script is obtained by choosing ‘Tools’, then ‘Forward
Engineering’, and then ‘Schema-Generation’ option available in the Menus and Toolbars
section and by clicking on the ‘Preview’ button.
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 32
Web and Database Technology-II (MCS-343L) SSUET/QR/114
Lab Exercises:
Reproduce the given databases using Erwin Data modeler.
Task 01:
Task 02:
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 33
Web and Database Technology-II (MCS-343L) SSUET/QR/114
Task 03:
Task 04:
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 34
Web and Database Technology-II (MCS-343L) SSUET/QR/114
Laboratory Exercise 05
Objective:
Follow instructions to design databases and generate their schema using Erwin
Theory:
Forward Engineering
ERwin offers a dominant feature called forward engineering that permits Database Developers
to transform the ER design into a schema generation SQL script for one or more target
relational databases. The resulting SQL script is obtained by choosing ‘Tools’, then ‘Forward
Engineering’, and then ‘Schema-Generation’ option available in the Menus and Toolbars
section and by clicking on the ‘Preview’ button.
Summary of the notation for ER diagrams
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 35
Web and Database Technology-II (MCS-343L) SSUET/QR/114
Lab Exercises:
Task 01:
Consider a mail order database in which employees take orders for parts from customers. The
data requirements are summarized as follows:
The mail order company has employees identified by a unique employee number, their
first and last names, and a zip code where they are located.
Customers of the company are uniquely identified by a customer number. In addition,
their first and last names and a zip code where they are located are recorded.
The parts being sold by the company are identified by a unique part number. In addirion,
a part name, their price, and quantity in stock are recorded.
Orders placed by customers are taken by employees and are given a unique order
number. Each order may contain certain quantities of one or more parts and their
received date as well as a shipped date is recorded.
Design an Entity-Relationship diagram for the mail order database and enter the design using
a data-modeling tool such as ERWin to generate its schema.
Task 02:
Consider a conference review system database in which researchers submit their research
papers for consideration. The database system also caters to reviewers of papers who make
recommendations on whether to accept or reject the paper. The data requirements are
summarized as follows:
Authors of papers are uniquely identified by their email id. Their first and last names are also
recorded.
Papers are assigned unique identifiers by the system and are described by a title, an abstract,
and a file name containing the actual paper.
Papers may have multiple authors, but one of the authors is designated as the contact author.
Reviewers of papers are uniquely identified by their email id. Their first and last names are also
recorded.
Each paper is assigned between two and four reviewers. The reviewer rates the paper assigned
to him on a scale of 1 to 10.
Each review contains two types of written comments: one to be seen by the review committee
only and the other by the author(s) as well.
Design an Entity-Relationship diagram for the conference review database and enter the design
using a data-modeling tool such as ERWin to generate its schema.
BS Mobile Communication and Security
Telecommunication Engineering Department
Sir Syed University of Engineering & Technology Page 36
Filename: MCS-343L W&DT-II Lab Manual
Directory: D:\Fall 2022\MCS-343
Template:
C:\Users\Administrator\AppData\Roaming\Microsoft\Templates\N
ormal.dotm
Title:
Subject:
Author: Anila Saghir
Keywords:
Comments:
Creation Date: 11/16/2022 11:43:00 AM
Change Number: 100
Last Saved On: 11/30/2022 12:02:00 PM
Last Saved By: Administrator
Total Editing Time: 264 Minutes
Last Printed On: 11/30/2022 12:03:00 PM
As of Last Complete Printing
Number of Pages: 45
Number of Words: 6,888 (approx.)
Number of Characters: 39,264 (approx.)