STAGES A Simple
Country Road
Requirement Stage Network
Component Design Database
Stage using MySQL
Implementation Stage By Azubuike Godswill
190405005
Requirement Stage
STAGES Component Design
Stage
Implementation Stage
REQUIRMENT STAGE
This stage involved a rough sketch creation
of my data model. This is where I thought of
the contents, relationships and constraints of
the data.
The idea is a create a simple road network
design that one can also use to analyse
accident rates and some traffic data.
This stage mainly focussed on thinking,
research and pen sketching.
The two main processes in this stage are:
Determine the purpose of your database
Find and organize the information
required
COMPONENT DESIGN
STAGE
Having all the requirements Processes to Database Design
to build my model, this stage i. Divide the information into
focussed on the design and tables.
creation of the model.
ii. Turn information items into
Here I created the tables columns.
added the attributes, iii. Specify primary keys.
relationships, as well as the
iv. Set up the table relationships.
business rules.
v. Refine your design.
The next slide describes the
processes stated here ->. vi. Apply the normalization rules
Turn information WeatherCondition
Divide the Columns contd.
information into items into columns Road Date
Information items here Name Temperature
tables
are the attributes of the Length Precipitation
Information here are entities and there are: SpeedLimit Visibility
the entities of the State
database. The RoadSegment
StateName
following are the StatePopulation
StartIntersection Specify primary
entities for the EndIntersection
keys
StateArea
database State – StateID
dialect
Accident LocalGovernment –
State LocalGovID
Date
LocalGovernment LocalGovernment
Time Wards – WardID
LocalGovName
Wards Severity Road – RoadID
LocalGovArea
Road LocalGovPopulation
Description RoadSegments –
SegmentID
Road Segments
TrafficData Accident – AccidentID
Accidents Wards
Timestamp TrafficData – TrafficData
Traffic Data
Wardname
AverageSpeed WeatherCondition -
population
WeatherCondition VehicleCount WeatherID
Adding Table Relationships, Specifying Cardinalities.
RoadSegments and TrafficData TrunkBRoad and LocalGovernment
ENTITY RELATIONSHIPS
Relationship = 1:N Non-Identifying Relationship = N:M Non-Identifying
Unary Relationships
Cardinalities : 1:1 - 1:N
Cardinalities : N:1 - 1:N
Tables– State , LocalGovernment
Binary Relationships RoadSegments and Accidents
Relationship = 1:N Non-Identifying
TrunkCRoad and Wards
State and LocalGovernment Tables
Cardinalities : 1:1 - 1:N Relationship = N:M Non-Identifying
Relationship = 1:N Non-Identifying
Cardinalities : N:1 - 1:M
Cardinalities : 1:1 - 1:N
Accidents and WeatherCondition
Relationship = 1:N Non-Identifying
TrunkARoad and TrunkBRoad
Wards and LocalGovernment Tables
Cardinalities : 1:1 - 1:N
Relationship = 1:N Non-Identifying
Relationship = 1:N Non-Identifying
SUPERTYPE AND SUBTYPES Cardinalities : 1:1 - 1:N
Cardinalities : 1:1 - 1:N
RELATIONSHIPS
Road(Supertype) – TrunkARoad , TrunkBRoad,
TrunkCRoad (Subtypes) TrunkBRoad and TrunkCRoad
Road and RoadSegments
Relationship = 1:N Non-Identifying
Relationship = 1:N Identifying
TrunkARoad and State Cardinalities : 1:1 - 1:N
Cardinalities : 1:1 - 1:N
Relationship = N:M Non-Identifying
Cardinalities : N:1 - 1:N
Database
Design
IMPLEMENTATION STAGE WITH MySQL
WORKBENCH 2. LINKING TABLES
For a Unary Recursive Relationship, click
1, TABLE CREATION
on the relationship on the side panel and
Launch MySQL Workbench from the then, double click the interested table.
start menu ( See 1)
On the home menu go to models For a Binary Relationship, choose the
Click the + sign to create a new relationship and click on both tables of
model interest. If relationship is 1:N, first click on
the many side, then the one side. ( See 2)
Edit the database name
For N:M Binary Relationships, click on the
Click on Add Diagram, this should
relationship and then both tables, this
take you to the worksheet.
automatically creates a joint table.
To create a table, click on the table For 1:N Binary relationships, non-
icon and click on the worksheet
identifying relations are automatically
Double click the table to edit its created. If one needs a non-identifying
name and columns (attributes). Also relationship, double click on the linking
assign datatypes to each attribute. crows foot line , go to foreign key , and
check identifying ( See 3)
To make an attribute a primary key,
just tick the PK and NN
For N:M Binary Relationships, a joint
2
4
NORMALIZATION
1st Normal Form
The database is of first normal form 2nd Normal Form
because:
A relation that is in First Normal Form and
There are only Single Valued every non-primary-key attribute is fully
Attributes. functionally dependent on the primary key,
Attribute Domain does not then the relation is in Second Normal Form
change. (2NF).
There is a unique name for Every attribute of a table in my database
every Attribute/Column. design depends solely on their primary key
The order in which data is with no partial dependencies. Hence, the
stored does not matter. database of a 2nd normal form
Boyce-Codd Normal Form
3rd Normal Form
Rule 1: The table should be in the
The database is of 3 normal
rd 3rd Normal Form.
form since every non-key Rule 2: X should be a superkey
attribute in a table depend on for every functional dependency
the key and nothing but the (FD) X−>Y in a given relation.
key. Both of these rules apply to the
tables in the database since every PK
They are no transitive is a superkey (No composite or other
dependencies in the database candidate keys ) and all attributes is
functionally dependent on it