Presentation is loading. Please wait.

Presentation is loading. Please wait.

Do it now – PAGE 13 You will find your do it now task in your workbook – look for the start button! Thursday, 20 September 2018.

Similar presentations


Presentation on theme: "Do it now – PAGE 13 You will find your do it now task in your workbook – look for the start button! Thursday, 20 September 2018."— Presentation transcript:

1 Do it now – PAGE 13 You will find your do it now task in your workbook – look for the start button! Thursday, 20 September 2018

2 Introduction to relational databases

3 Learning Objective “Investigate how to minimise data duplication through the use of a relational database” You will find differentiated outcomes for this lesson on the front of your workbook. Thursday, 20 September 2018

4 New learning In order to design a relational database you must normalise your entities so that: all possible relationships between data are allowed the duplication of data is minimised Minimising duplicated data is important as it can lead to inconsistencies in the database. For example, in an unnormalised database it would be possible to have two records for the same customer. This could lead to a situation where one of the records was updated with the customer’s new address and the other with their new telephone number - it could lead to all sorts of difficulties communicating with this customer.

5 New learning

6 New learning UNF – 1NF Identify the repeating and non-repeating attributes Separate out the non-repeating and repeating attributes

7 New learning UNF – 1NF Identify the primary keys and create a foreign key to link the two tables

8 New learning 1NF – 2NF Anything already only reliant on a single key is already in 2NF

9 New learning 1NF – 2NF Identify anything not reliant on the composite key and separate out

10 New learning 1NF – 2NF While in 2NF anything separated out is still under the same primary key they went under in 1NF

11 New learning 2NF – 3NF Each attribute in an entity should rely only on the primary key and not on another attribute

12 Learning Development Table Order Burgers
Our relationship diagram now looks like this – 1 table can make any orders, one type of burger can be in many orders

13 Independent Task CREATE TABLE ProductType( ProductTypeID Integer, Description text, Primary Key(ProductTypeID)) Using the SQL above for guidance create a tables table – you cannot name it table – why?

14 Independent Task CREATE TABLE Product( ProductID Integer, Name text, Price real, ProductTypeID Integer, Primary Key(ProductID), Foreign Key(ProductTypeID) references ProductType(ProductTypeID)) Using the SQL above for guidance create a food_orders table – you cannot name it order – why? You will need to add extra foreign keys

15 Learning Development PRAGMA Foreign_Keys = ON
Use lesson 2 to help you to populate your tables Can you work out how to query more than one table at a time? SQLite does not check for foreign key restrains as default – this needs to be turned on – what might happen if you do not turn this on?

16 Talk Task What is the name given to a database that has multiple linked tables? What is meant by normalisation? Explain a situation where a relational database would be used What must be added to the SQL for creating the table if the table is linked to another? Why is using a relational database more suitable for updating and deleting data than a flat file database? Based on what you know explain how a relational database works

17 Table is known as a restricted word, what does this mean?
Exit ticket Table is known as a restricted word, what does this mean? R A G


Download ppt "Do it now – PAGE 13 You will find your do it now task in your workbook – look for the start button! Thursday, 20 September 2018."

Similar presentations


Ads by Google