9 ist t3 l7 database relation query
DESCRIPTION
Episode 7 of the series for Year 9 looking at the topic of databases. Focus Relational Databases and QueriesTRANSCRIPT
Relational Databases9IST Information Software Technology
T3L7 - Introducing relationships in DBMS
www.cannedteacher.com
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
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
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.
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
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.
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
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
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)
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
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.
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
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’
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=