Presentation is loading. Please wait.

Presentation is loading. Please wait.

Entity relationship diagrams

Similar presentations


Presentation on theme: "Entity relationship diagrams"— Presentation transcript:

1 Entity relationship diagrams
Mr Hall What is an Entity Relationship Diagram (ERD)? An entity relationship diagram (ERD) shows the relationships of entity sets stored in a database. An entity in this context is a component of data. In other words, ER diagrams illustrate the logical structure of databases

2 Starter what is a primary key

3 Before building any database you should know:
The entities Relationships Attributes

4 What is an entity? Entities:
Each database table is about an object, person or thing: E.g. Customers Videos Products Teachers

5 Attributes Attributes relate to the thing….. E.g. A DVD is the entity
The attributes of the DVD are:…………………….. Relationships are how the data links together.

6 If a key is not a PK what is it ?

7 Three types of entity relationship in DBMS software
One to one One to many Many to many

8

9

10

11 Cardinality –line design between entities!

12 Student ERD task 1 Using the attributes and the entities in the image below place the correct cardinality on the ERD diagrams

13 Answer to student task 1 One to many relationship

14 why does order number have a pk next to it ?
What does Key mean?

15 Student task 2 You are charge of setting up a new database for the school system. You know that there are 5 major Entities in the model. These are: Classes Teachers Students Grades Rooms Draw the ERD for this model, detailing the Primary and Foreign keys for each table

16 Example of Entity Relation Diagrams

17

18

19 What are keys and why do you need to know them for creating an ERD
Primary Keys are unique in that table, they cannot be duplicated Foreign Keys are linking the Primary key to another table Before building any database you should know: The entities Relationships Attributes

20 Different keys within a database design

21 What would be suitable primary keys for product and customer entities ?

22 Answer ? PK PK

23

24

25

26 Database task Activity 1: Entity relationship diagram-Produce an entity relationship diagram (ERD) for the database by normalizing the given data to third normal form. Now we know what ERD diagrams are and how relationships are created we now need to know how to normalize data to achieve this

27 Firstly what is normalization-1nf
the idea is is put very simply, that you reduce data down to its atomic level. The technical word is atomicity .A good way of doing that would be for example making changes to a entity so that it did not contain duplicate values So I hear you ask . What is the issue with this set of data structures we are planning to start our design off with ?

28 Part 1 what is the problem ?
Table one has an address entity that has multiple data sets in Address should be split into separate sections ,possibly in a new entity table all of its own .IT IS NOT ATOMIC It cannot have more than one value to be 1st normal form The column is the issue here as it should not be all in one Part 2-what is the problem ? Two s have been entered for 1 requested value .This means it cant be atomic and so is not 1st normal form **data integrity issue** Part 3-What is the problem ? Primary key should be in here only once .As it is a primary key it should be a unique identifier .If it was a foreign key it would be no problem. **data integrity issue here with two addresses**

29 Solution part 1 Solution part 2
We have split all aspects of address down to atomic level Solution part 2 _id is a primary key and holds the individual atomic data User_id is a foreign key hence it is allowed to have duplicate data User_id references the primary key in table 1

30 Firstly what is normalization-2nf
The idea of 2nf is that you must first be in 1st normal form and then you need to remove all partial dependencies. There must be complete dependencies in each entity. Isbn can only be in book entity table as it is dependent or fully related to book_author. Isbn would not go in book_author as it is only partially dependent on book_author

31 Firstly what is normalization-3nf
To get to 3nf you need to have completed 1nf and 2nf. 3nf is about removing what are called transitive dependencies Look at the following table What is the issue and what is the solution

32 3nf what is wrong with table
This table is a good example of transitive dependency The star meaning depends upon the star That is bad. The star then depends upon the review_id Solution :split off the attributes into different tables to end transitive dependency All of the transitive dependencies have now been removed

33 Task 1:Produce an entity relationship diagram (ERD) for the database by normalizing the given data to third normal form.


Download ppt "Entity relationship diagrams"

Similar presentations


Ads by Google