Design: 2.1 Entity-Relationship Diagram

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Chapter 2

DESIGN

System design is the process of defining the architecture, modules, interfaces,


and data for a system to satisfy specified requirements. System design could be seen as
the application of systems theory to product development. There is some overlap with
the disciplines of systems analysis, systems architecture and systems engineering.
The Jewellery Management system Application is designed in such a way that it helps
user to make their own decision to choose the jewels. Mainly this Application is user
friendly.

Fig 2.0: Design of Jewellery Management System.

2.1 ENTITY-RELATIONSHIP DIAGRAM:


An Entity-Relationship model (ER model) is usually the result of systematic analysis to
define and describe what is important to processes in an area of a business. It does not
define the business processes; it only presents a business data schema in graphical form.
It is usually drawn in a graphical form as boxes (entities) that are connected by lines
(relationships) which express the associations and dependencies between entities. An ER
model can also be expressed in a verbal form, for example: one building may be divided
into zero or more apartments, but one apartment can only be located in one building.
Entities may be characterized not only by relationships, but also by additional properties
(attributes), which include identifiers called "primary keys". Diagrams created to

Dept of ISE, BNMIT 2019-20 Page 3


Jewellery Management System

represent attributes as well as entities and relationships may be called entity-attribute-


relationship diagrams, rather than entity–relationship models.
An ER model is typically implemented as a database. In a simple relational database
implementation, each row of a table represents one instance of an entity type, and each
field in a table represents an attribute type. In a relational database a relationship between
entities is implemented by storing the primary key of one entity as a pointer or "foreign
key" in the table of another entity. The Entity-Relationship model of Jewellery
Management System is shown in Fig 2.1.
An ER-Diagram contains the following features:

 Entities
 Relations
 Attributes
 Cardinality ratios.
The Regular Entities of Jewellery Management System are:

 Jewel
 Customer
 Booking
 Offers
 Transaction log

Their Attributes are:

 Jewel ( jewel_id , image, brand, name, size, amount, type, count, discount)
 Customer ( customer_id, name, dob, email, gender, phone, country, state, district,
address, password)
 Booking ( book_id, customer_id, jewel_id, date, grand_total, status)
 Offers ( jewel_id, discount)
 Transaction_log ( transaction_id, date)

ER Diagram Description:

An entity-relationship diagram (ERD) is a data modeling technique that graphically


illustrates an information system’s entities and the relationships between those entities.
An ER Diagram is a conceptual and representational model of data used to represent the
entity framework infrastructure.

Dept of ISE, BNMIT 2019-20 Page 4


Jewellery Management System

Steps involved in creating an ER Diagram include:

1. Identifying and defining the entities.


2. Determining all interactions between the entities.
3. Analyzing the nature of interactions/determining the cardinality of the
relationships.
4. Creating the ER Diagram.

Fig 2.1: ER diagram for Jewellery Management System

2.2: STEPS FOR ER TO RELATIONAL MAPPING

 ER-to-Relational Mapping Algorithm


 Step 1: Mapping of Regular Entity Types
 Step 2: Mapping of Weak Entity Types
 Step 3: Mapping of Binary 1:1 Relation Types
 Step 4: Mapping of Binary 1: N Relationship Types.

Dept of ISE, BNMIT 2019-20 Page 5


Jewellery Management System

 Step 5: Mapping of Binary M: N Relationship Types.


 Step 6: Mapping of Multivalued attributes.
 Step 7: Mapping of N-ary Relationship Types.
Step 1: Mapping of Regular Entity Types

o For each regular (strong) entity type E in the ER schema, create a relation
R that includes all the simple attributes of E.
o Choose one of the key attributes of E as the primary key for R.
o If the chosen key of E is composite, the set of simple attributes that form it
will together form the primary key of R.
Step 2: Mapping of Weak Entity Types

o For each weak entity type W in the ER schema with owner entity type E,
create a relation R & include all simple attributes (or simple components
of composite attributes) of W as attributes of R.
o Also, include as foreign key attributes of R the primary key attribute(s) of
the relation(s) that correspond to the owner entity type(s).
o The primary key of R is the combination of the primary key(s) of the
owner(s) and the partial key of the weak entity type W, if any.
Step 3: Mapping of Binary 1:1 Relationship Types

o For each 1:1 relationship type R, identify the relations S and T that
participating in R.
Foreign key approach

o Choose one relation S. Include the primary key of T as a foreign key in S.


o It is better to choose an entity type with total participation in R in the role
of S.
Step 4: Mapping of Binary 1:N Relationship Types

o For each binary 1:N relationship type R, identify the relation S that
represents the participating entity type at the N-side of the relationship.
Let T denotes the other participating entity.
o Include the primary key of T as a foreign key in S.
o Include any simple attributes of the relationship as attributes of S.
Step 5: Mapping of Binary M:N Relationship Types

o For each binary M:N relationship type R, create a new relation S.


o Include the primary keys of both participating entities as foreign keys.

Dept of ISE, BNMIT 2019-20 Page 6


Jewellery Management System

o Their combination will form the primary key of S.


o Also include any simple attributes of R.
Step 6: Mapping of Multivalued attributes.

o For each multivalued attribute A, create a new relation R.


o This relation R will include an attribute corresponding to A, plus the
primary key attribute K (as a foreign key in R) of the relation that
represents the entity type of relationship type that has A as an attribute.
o The primary key of R is the combination of A and K. If the multivalued
attribute is composite, we include its simple components.
Step 7: Mapping of N-ary Relationship Types.

o For each n-ary relationship type R, where n>2, create a new relation S to
represent R.
o Include as foreign key attributes in S the primary keys of the relations that
represent the participating entity types.
o Also include any simple attributes of the n-ary relationship type (or simple
components of composite attributes) as attributes of S.
Table 2.1 Key Correspondence between ER and Relational Models

ER Model Relational Model


Entity type “Entity” relation
1:1 or 1:N relationship type Foreign key (or “relationship” relation)
M:N relationship type “Relationship” relation and two foreign
keys
n-ary relationship type “Relationship” relation and n foreign keys
Simple attribute Attribute
Composite attribute Set of simple component attributes
Multivalued attribute Relation and foreign key
Value set Domain
Key attribute Primary (or secondary) key

2.3 RELATIONAL DATABASE SCHEMA:


A database is a collection of interrelated data files or structures. It is designed to meet the
various information needs of the organization. Also, it is integrated and shared. Thus, a
relational database schema is an arrangement of relation states in such a manner that

Dept of ISE, BNMIT 2019-20 Page 7


Jewellery Management System

every relational database state fulfills the integrity constraints set on a relational database
schema.

Fig.2.2 Relational Model – Database Schema for Jewellery Management System

The fig.2.2 shows the schema for Jewellery Management System. The schema has
Horizontal blocks representing the entities of the particular attribute. The line from an
entity pointing to the other entity shows that particular entity is referenced.

2.4 FUNCTIONAL DEPENDENCIES:

A functional dependency (FD) is a relationship between two attributes, typically between


the Primary Key and other non-key attributes within a table. For any relation R, attribute
Y is functionally dependent on attribute X , if for every valid instance of X, that value of
X uniquely determines the value of Y.
Types of Functional Dependencies

 Trivial functional dependency


 Non-trivial functional dependency

Dept of ISE, BNMIT 2019-20 Page 8


Jewellery Management System

 Multivalued dependency
 Transitive dependency
The functional dependencies for Jewellery Management System are:
 Jewel : Jewel_id {jewel_id, image, brand, name, size, amount, type, count,
discount}
 Customer:customer_id {customer_id, name, dob, email, gender, phone,
country, state, district, address, password}
 Booking:book_id {book_id, customer_id, jewel_id, date, grand_total, status}
 Offers {jewel_id, discount}
 Transaction_log:transaction_id {transaction_id, date}
2.5 NORMALIZED RELTIONAL SCHEMA:

First Normal Form:

The relation is said to be in 1NF if it has no repeating groups. All tables have no repeating
groups so they are in 1NF.

1. jewel :-
image, jewel_id, brand, name, size, amount, type, count, discount.

image Jewel_id brand name size amount type Count discount

2. customer :-
customer_id, name, dob, email, gender, phone, country, state, district, address,
password.

Customer_id Name dob Email gender phone country state district address password

3. bookingdetails :-
book_id, customer_id, jewel_id, date, grandtotal, status.

Book_id Customer_id Jewel_id date grandtotal status

4. offers :-
jewel_id, discount.

Jewel_id Discount

Dept of ISE, BNMIT 2019-20 Page 9


Jewellery Management System

5. transaction_log :-
t_id, date.

T_id Date

Second Normal Form:

A relation is said to be in 2NF if it is already in 1NF and it has no partial dependency.

1. jewel:-
The absence of partial dependency in relation takes it into 2NF without any
modifications.

image Jewel_id brand name size amount type Count discount

2. customer:-
The absence of partial dependency in relation takes it into 2NF without any
modifications.

Customer_id Name dob Email gender phone country state district address password

3. bookingdetails :-
The absence of partial dependency in relation takes it into 2NF without any
modifications.

Book_id Customer_id Jewel_id date grandtotal status

4. offers :-
The absence of partial dependency in relation takes it into 2NF without any
modifications.

Jewel_id Discount
5. Transaction_log :-
The absence of partial dependency in relation takes it into 2NF without any
modifications.

T_id Date

Dept of ISE, BNMIT 2019-20 Page 10


Jewellery Management System

Third Normal Form:

A relation is said to be in 3NF if it is already in 1NF and 2NF and has no


transitive dependency.

1. jewel :-
In jewel, every attribute depends on primary key so it is in 3NF.

image Jewel_id brand name size amount type Count discount

2. customer:-
In customer, every attribute depends on primary key so it is in 3NF.

Customer_id Name dob Email gender phone country state district address password

3. booking details:-
In bookingdetails, attributes depend on primary key so it is in 3NF.

Book_id Customer_id Jewel_id date grandtotal status

4. offers :-
In offers, attributes depend on primary key so it is in 3NF.

Jewel_id Discount
5. transaction_log :-
In transaction_log, attributes depend on primary key so it is in 3NF.

T_id Date

Fourth Normal Form:

4NF is concerned with multivalued dependency. A table is in 4NF if and only if, for every
one of its non-trivial multivalued de3pendencies X-->>Y, X is superkey i.e. X is either a
candidate key or a superset thereof.

Fifth Normal Form:

5NF also known as Project Join Normal Form (PF/NF) is a level of database
normalization designed to reduce redundancy in relation databases recording multivalued
facts by isolating semantically related multiple relationships. A table is said to be in 5NF
if and only if every non-trivial join dependency in that table

Dept of ISE, BNMIT 2019-20 Page 11


Jewellery Management System

2.6 KEY ATTRIBUTES:

The table 2.2 describes the Key attributes present in the database with primary key
and foreign key.

Table 2.2 Key Attributes used in Jewellery Management System

ENTITY PRIMARY KEY

JEWEL JEWEL_ ID
CUSTOMER CUSTOMER_ID
BOOKING BOOK_ID
OFFERS JEWEL_ID
TRASACTION_LOG TRANSACTION_ID

PRIMARY KEY

A column or group of columns in a table which helps us to uniquely identifies every row
in that table is called a primary key. This DBMS can't be a duplicate. The same value
can't appear more than once in the table.
The Primary Key Attributes used in database are : jewel_id, customer_id, book_id,
transaction_id.

FOREIGN KEY

A foreign key is a column which is added to create a relationship with another table.
Foreign keys help us to maintain data integrity and also allows navigation between two
different instances of an entity. Every relationship in the model needs to be supported by
a foreign key.

NOT NULL

The not-null constraint is a restriction placed on a column in a relational database table. It


enforces the condition that, in that column, every row of data must contain a value - it
cannot be left blank during insert or update operations.
The each entity specified in database are considered with not-null constraint.

Dept of ISE, BNMIT 2019-20 Page 12


Jewellery Management System

THE DEFAULT SQL CONSTRAINT

The DEFAULT constraint is used to provide a default value for a column. The
default value will be added to all new records IF no other value is specified.

THE CHECK CONSTRAINT

A check constraint is a type of integrity constraint in SQL. Which specifies a requirement


That must be met by each row in a database table. The constraint must be a predicate. It
Can refer to a single column, or multiple column, or multiple columns of the table.

Dept of ISE, BNMIT 2019-20 Page 13

You might also like