150 likes | 410 Views
Relational Database. Need to Knows. Data - is just a pile of numbers or stats. A business "organises" the data to be meaningful and help make decisions. Database (DB) – brings “order” to the data using relationships. What is a database?. It is a DB with 1 table only
E N D
Relational Database Need to Knows
Data - is just a pile of numbers or stats. • A business "organises" the data to be meaningful and help make decisions. • Database (DB) – brings “order” to the data using relationships. What is a database?
It is a DB with 1 table only • An excel spreadsheet is an example of a flat file database. • It stores information in columns and rows. • Column – a field or entity e.g. customer name or date of birth; • Row – a record e.g. a customer • Table – a collection of columns and rows e.g. customers What’s a Flat File database?
Typical spreadsheet that shows Sales Reps, their hourly rates and email details. • Note – Column e.g. Name; Row e.g. Ayla’s name, pay rate and email address. Flat File Example
What if you wanted to track the Sales Reps projects they were working on, and hours? • We could add two more columns e.g. Job Description and Job Hours. • If Carla does 3 different projects, we’d need to enter her 3 times in the spreadsheet. Flat File cont…
Redundancy – the same data duplicated in multiple places e.g. Carla’s email address. • What if this flat file had 1000 records, and she changed her email address? • Inefficient way to keep track of data using a single table Problems?
Use two tables to track the same information – Sales Rep table that stores all information about the Sales Reps. • Then create a second Job Table to track all the jobs the sales reps do. • Decreases redundancy because if her email or pay rate change, just change it in the one place i.e. customer table. Better solution?
Anomalies – what happens if I accidentally delete Carla from the Sales rep table? • In a flat file DB like this spreadsheet, there is no “integrity” checks to make sure “orphan” entries don’t happen. • To avoid Anomalies, Redundancy and to improve data efficiency, use a Relational Database. Problem?
Entity – A table should be a collection of data about a single “entity” or “theme” e.g. customer; employee; orders; • Field – the column headings that describe the entity e.g. customer firstname; customer lastname; DOB; Email; Phone; • Data Type – specifies what type of data can be stored in a field e.g. Number or Text. From Flat File to Relational:
Look at this spreadsheet, what “entities” or tables could you pull from this data? • Clue – look at fields/columns that duplicate information. Identifying Entities…
Now try and write what fields and their types you’d have under each table. • When you have had these ticked off by Miss, look at the information in the assessment task on the wiki, and complete Database Design Task 1a) • You can either use the sample data in the task, OR your own club/information. What Fields and Types?