Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming In a well-designed...

49
INFORMATION MODELING: 1.ENTITY RELATION DIAGRAMS (ERD) 2. THE OSI LAYERING MODEL 3. NORMALIZING DATA Information Engineering Dr B. Mills

Transcript of Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming In a well-designed...

Page 1: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

INFORMATION MODELING:

1.ENTITY RELATION DIAGRAMS (ERD)

2. THE OSI LAYERING MODEL

3. NORMALIZING DATA

Information EngineeringDr B. Mills

Page 2: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

ERD – Entity Relation Diagramming

In a well-designed relational database, each table represents an entity. In the figure below there are 4 entities(tables): Customers, Line Items, Invoices, Products.

First we must understandentities

Page 3: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

EntitiesA database contains one or more related tables.Each table holds all of the information about an

object, person or thing.Some examples of database tables might be: - a customer table - an appointments table - an exam sessions table - a teachers' names table - a concert venue table

ERD – Entity Relation Diagraming

Page 4: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Tables are entities

Each table is about an object, person, or thing.

CustomersAppointmentsBooksStudentsProducts

These are entitiesand could be membersof one database or differentdatabases

ERD – Entity Relation Diagraming

Page 5: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Entities have attributes

Entity = Customers.CustomerIDFirstNameLastNameData of BirthAddress

These are attributes of the customer entity

ERD – Entity Relation Diagraming

Page 6: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Entities have attributes

Entity = Products.ProductIDProductNameWeightManufacturerWarehouse

These are attributes of the products entity

ERD – Entity Relation Diagraming

Page 7: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Entities= Customer, Products, Orders

CustomersProductsOrders

There is a link betweenthe 3 entities

This is known as a relationship

ERD – Entity Relation Diagraming

Page 8: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Entity Relationship Diagrams These relationships can be shown in the form of a

diagram. This diagram is known as an 'entity relationship

diagram', E-R diagram or ERD As part of your exam, you will have to draw or interpret

an E-R diagram. Before you can do this, you need to be able to interpret the relationships between the entities.

  These relationships take the form of: - one-to-one - one-to-many - many-to-many

Page 9: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

One-to-One

A husband can only have one wife A wife can only have one husband this would be known as a 'one-to-one

relationship' This relationship in a diagram would

look like this:

Page 10: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

One-to-Many

A mother can have many children A child can have only one mother this would be known as a 'one-to-

many relationship' This diagram looks like this:

Page 11: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Many-to-Many Think about a library A book can be read by many people People can read many books this would be known as a 'many-to-

many relationship‘ This relationship looks like this:

Page 12: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Modeling Your DataWhen designing a data model you should first determine the following: > The ‘Many’ side usually contains the foreign key

> The ‘One’ side usually contains the primary key

Before you design or set up a database, you should work out:

- the entities - the attributes - the entity relationships This process is called 'data

modelling'

Page 13: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

What The 7 – Layer OSI Model IS:.

Defines a necessary elements for data communication between devices.

Defines a communication architecture, for digital comuntication systems

Visually and conceptually separates communication, network, and software functions

Page 14: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

What The 7 – Layer OSI Model IS:.

Defines a necessary elements for data communication between devices.

Defines a communication architecture, for digital comuntication systems

Visually and conceptually separates communication, network, and software functions

Page 15: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

OSI Model Definition – 7 Layers

Layer 1 – Physical Layer 2 – Data

Link Layer 3 – Network Layer 4 –

Transport Layer 5 – Session Layer 6 –

Presentation Layer 7 -

Application

Please Do Not Throw Sausag

e Pizza Away

7654321

Page 16: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

How data moves through the layers

Page 17: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Layer 7 - Application

Examples: Internet Explorer, Safari, and other browsers FTP Mail

Many applications that run on your computer are NOT part of the Application layer. This means that the following are not part of layer 7 because they do not request network services: Microsoft Word or Excel Adobe Photoshop

The Application layer provides services to the software through which the user requests

network services.

Physical – Data Link – Network – Transport – Session – Presentation - Application

Page 18: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Layer 6 - Presentation

For outgoing messages, it converts data into a generic format for network transmission; for incoming messages, it converts data from the generic network format to a format that the receiving application can understand

This layer is also responsible for certain protocol conversions, data encryption/decryption, or data compression/decompression

Examples: MIDI JPG, GIF, TIF MPEG

Manages data-format information for networked communications (the network’s translator)

Physical – Data Link – Network – Transport – Session – Presentation - Application

Page 19: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Layer 5 - Session

Responsible for initiating, maintaining and terminating sessions Responsible for security and access control to session

information (via session participant identification) Responsible for synchronization services, and for checkpoint

services Examples:

NFS SQL RPC

The Session layer establishes, maintains, and manages the communication session between computers.

Page 20: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Layer 4 - Transport

Manages the transmission of data across a network Manages the flow (flow control) of data between parties by

segmenting long data streams into smaller data chunks (based on allowed “packet” size for a given transmission medium) (packet sequencing)

Provides acknowledgements of successful transmissions and requests retransmission for packets which arrive with errors (error detection and recovery)

Examples: TCP UDP

The functions defined in this layer provide for the reliable transmission of data segments, as well as the disassembly and assembly of

the data before and after transmission.

Page 21: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Layer 3 - Network

Handles addressing messages for delivery, as well as translating logical network addresses and names into their physical counterparts (Logical Addresses are managed by local network admins.)

Responsible for deciding how to route transmissions between computers This layer also handles the decisions needed to get data from one point

to the next point along a network path This layer also handles packet switching and network congestion control Example:

IP Network routers

The Network layer defines the processes used to route data across the network and the structure and use of logical addressing.

Physical – Data Link – Network – Transport – Session – Presentation - Application

Page 22: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Layer 2 – Data Link

Handles special data frames (packets) between the Network layer and the Physical layer

At the sending end this layer handles conversion of data into raw formats that can be handled by the Physical Layer. At the receiving end, this layer packages raw data from the physical layer into data frames for delivery to the Network layer

The data link layer is often conceptually divided into two sub-layers: logical link control (LLC) and media access control (MAC).

Examples: Network bridges Ethernet Wi-Fi

Concerned with the linkages and mechanisms used to move data about the network and deals with the ways in which

data is reliably transmitted.

Physical – Data Link – Network – Transport – Session – Presentation - Application

Page 23: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Layer 1 - Physical

Converts bits into electronic signals for outgoing messages. Converts electronic signals into bits for incoming messages

This layer manages the interface between the computer and the network medium (coax, twisted pair, etc.)

This layer tells the driver software for the MAU (media attachment unit) (eg. network interface cards (NICs), modems) what needs to be sent across the medium

Examples: Network hubs and repeaters LAN and WAN topology

This layer defines the electrical and physical specifications for the networking media that

carry the data bits across a network.

Physical – Data Link – Network – Transport – Session – Presentation - Application

Page 24: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

NORMALIZATIONAdvanced Topic

Page 25: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Normalization

In the field of Relational Database design, normalization is a way of ensuring that a database structure is suitable for general-purpose querying and free of certain undesirable characteristics that could lead to a loss of Data integrity

Page 26: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Data Integrity

Refers to the validity of data The assurance that data is accurate,

correct and valid to the validity of data

Page 27: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

What is Normalization?

Database normalization is the practice of optimizing table structures. Optimization is done by a complete investigation of the various pieces of data that will be stored within the database

Page 28: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

An Introduction to Database Normalization - Preliminary Definitions

Terminology in Normalization:

Entity: The word ‘entity’ as it relates to databases can simply be defined as the general name for the information that is to be stored within a single table.

Example: for storing information about the school’s students, then ‘student’ would be the entity.

The student entity would likely be composed of several pieces of information, for example:

student identification number, name, and email address. These pieces of information are better known as attributes.

Page 29: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Relationship Understanding the relationships between

the data items forming the various entities and between the entities themselves forms the foundation of database normalization.

Remember, there are three types of data relationships that you should be aware of:

One-to-One One-to-Many Many-to-Many

Page 30: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Foreign Key and ERD

Foreign key: A foreign key forms the basis of a One-to-Many relationship between two tables. The foreign key can be found in the Many table, and points to the primary key found in the One table

Entity-relationship diagram (ERD): An ERD is a graphical representation of the database structure. An ERD can be created using sophisticated software or drawn on a piece of paper from your pocket.

Page 31: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

We want to eliminate data redundancy Redundancy happens when the same data values

are stored more than once in a table, or when the same values are stored in more than one table.

To prevent redundancy, normalization is done to improve performance when performing CRUD operations, especially searching for information

One of the biggest disadvantages of data redundancy is that it increases the size of the database unnecessarily. Also data redundancy might cause the same result to be returned as multiple search results when searching the database causing confusion and clutter in results.

Page 32: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Avoiding Redundancy

Page 33: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Analysis

This table maps (points to) various students to the classes found within their schedule.

Issues: Assuming that the only intention of this table

is to create student-class mappings, then there really is no need to repeatedly store the class time and professor ID.

if there are 30 students to a class, then the class information would be repeated 30 times over

Page 34: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Why avoid Redundancy?

Redundancy introduces the possibility for error. the name of the class found in the final row in

the table (Matj 148). Given the name of the class found in the first

row, chances are that Matj 148 should actually be Math 148!

While this error is easily identifiable when just four rows are present in the table, imagine finding this error within the rows representing the 60,000 enrolled students

Page 35: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Database Normalization - The Three Normal Forms

The process towards database normalization progressing through a series of steps, typically known as Normal Forms.

Page 36: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

First Normal Form (1NF)

Converting a database to the first normal form is rather simple.

The first rule calls for the elimination of repeating groups of data through the creation of separate tables of related data.

Page 37: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Breaking bigger tables down into several smaller tables. The first table contains solely student information (Student):

Page 38: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

The second table contains solely class information (Class):

Page 39: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

The third table contains solely professor information (Professor):

Page 40: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Second Normal form

Once you have separated the data into their respective tables, you can begin concentrating upon the rule of Second Normal Form-

-the elimination of redundant data. Referring back to the Class table, typical data stored within might look like:

Page 41: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Second Normal Form (2NF)

Page 42: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

While this table structure is certainly improved over the original, notice that there is still room for improvement.

In this case, the className attribute is being repeated. With 60,000 students stored in this table, performing an update to reflect a recent change in a course name could be somewhat of a problem. Therefore:

create a separate table that contains classID to className mappings (ClassIdentity):

Page 43: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Class Identity

Page 44: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

The updated Class table would then be simply:

Page 45: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Third Normal Form (3NF)

For complete normalization of the school system database, the next step in the process is to satisfy the rule of the Third Normal Form.

This rule seeks to eliminate all attributes from a table that are not directly dependent upon the primary key. In the case of the Student table, the college and college Location attributes are less dependent upon the student ID than they are on the major attribute. Therefore, we’ll create a new table that relates the major, college and college Location information:

Page 46: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Third Normal Form

Page 47: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

The revised Student table would then look like:

Page 48: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Some other Database Terms…

Data Mining Data Matching Distributed Databases Boolean Operators SQL Servers

Page 49: Information Engineering Dr B. Mills. ERD – Entity Relation Diagramming  In a well-designed relational database, each table represents an entity. In the.

Summary

Normalization is a systematic way of ensuring that a database structure is suitable for general-purpose querying and free of certain undesirable characteristics—insertion, update, and deletion anomalies—that could lead to a loss of data integrity.