14

Click here to load reader

9 Ist T3 L7 Database Relation Query

  • Upload
    pmhs

  • View
    1.100

  • Download
    0

Embed Size (px)

DESCRIPTION

Episode 7 of the series for Year 9 looking at the topic of databases. Focus Relational Databases and Queries

Citation preview

Page 1: 9 Ist T3 L7 Database Relation Query

Relational Databases9IST Information Software Technology

T3L7 - Introducing relationships in DBMS

www.cannedteacher.com

Page 2: 9 Ist T3 L7 Database Relation Query

About this show

• Learn about

• Using multiple tables in a DBMS

• Saving time and being flexible

• Advantages of Relational Databases over Flat File Databases

• Describing a Relational Database

Page 3: 9 Ist T3 L7 Database Relation Query

Relationships

• a way in which people and things are connected to each other

• husband and wife• father and son• brother and sister• transmission and engine

Page 4: 9 Ist T3 L7 Database Relation Query

Relational DBMS

• When a Database contains facts that are organised into more than one table

• If the facts have some ‘relationship’ that can be used to produce information as a result of BOTH tables

• The resulting information is generated because of a relationship that the designer has made.

Page 5: 9 Ist T3 L7 Database Relation Query

2 Table Example

• Table 1 : The student table - contains facts about a student (name, address, year etc)

• Table 2 : The class table - contains facts about classes in school (year, subject)

• If we want to generate a report about which students are in which class we could take advantage of a RELATIONAL DATABASE

Page 6: 9 Ist T3 L7 Database Relation Query

What if we use 1 table?

• If we use 1 table, we have to manually enter the names of the classes the students are for EACH student.

• Requires more storage, takes longer and causes REDUNDANCY

• REDUNDANCY - saying things over and over when you could say them once.

Page 7: 9 Ist T3 L7 Database Relation Query

Relational tablesStudent tbl Class tbl Year tbl

Name (text)AddressYear

artd&tcomputingmathsenglishgeographyhisepdhpe

789101112Using 3 tables that

are related - we can ‘pull’ information together that we need to form the class information

Page 8: 9 Ist T3 L7 Database Relation Query

Why do this?

• Because we have 1 simple table to manage the facts (data) about the possible years

• 1 simple table about the subjects.

• We can add, change or delete subjects from this table really easily - and use these facts in other places too

• We can keep a simple record of a student and use these facts in other places too

Page 9: 9 Ist T3 L7 Database Relation Query

Why do this?

• Having data broken up into smaller, simpler tables makes it easier to manage and more flexible.

• we dont need to repeat ourselves over and over and so use less space and less time

• If a table becomes corrupt - it is easier to RESTORE (fix)

Page 10: 9 Ist T3 L7 Database Relation Query

Creating a class table

• What fields to we need to create a class table?

• name/year/subject

• so we can generate this table by ‘looking up’ facts from the first 3 we made.

• this is called a LOOKUP

• Look up the stuff you want and put it in

Page 11: 9 Ist T3 L7 Database Relation Query

Finding who’s who?

• This is done in s DBMS by asking questions

• Asking questions is called QUERYING

• If theres something wrong with a price at the shops, people often ‘query’ the bill with the cahier?

• Does the store have what I want - you ask a member of staff - this too is a QUERY.

Page 12: 9 Ist T3 L7 Database Relation Query

Querying• The question we would need to ask the

DBMS for a class list is simple

• What STUDENTS are Maths

• SELECT names WHERE class = Maths

• what information would you get if you asked these ...

• SELECT names WHERE class <> Maths

• SELECT names WHERE class = Maths and year = 9

Page 13: 9 Ist T3 L7 Database Relation Query

Summary

• Relational Databases are

• Good ways to break down ‘facts’ that can be re-used to remove REDUNDANCY

• Effective ways to asks questions - QUERY the data to produce new information

• Lower storage needs and increase speed

• Guard against terminal ‘data loss’

Page 14: 9 Ist T3 L7 Database Relation Query

Activity

• Using a video camera in groups of 4

• Think about a ‘role play’ in which your group can describe the idea of a RELATIONAL DATABASE - perhaps each person plays the role of a table and someone else pretends to be the database manager.

• Role play how a query works.

click

Watch This!

http://www.youtube.com/watch?v=GVOnFdMf0RU&mode=related&search=