GCSE COMPUTER SCIENCE Data 2.4 Databases & SQL.

Slides:



Advertisements
Similar presentations
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Advertisements

Start First step Create a new blank database Create a database using the option that will enable you to build your database using pre-set options. Save.
Create a new blank database First step SUBMITTry again.
Information systems and databases Database information systems Read the textbook: Chapter 2: Information systems and databases FOR MORE INFO...
Database Software Application
Your Tour Guide is Jim Provensal. What We Will Cover s Introduction to MicroSoft Access u What is a database u What is a “Relational” Database s The Major.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
2440: 141 Web Site Administration Database Management Using SQL Professor: Enoch E. Damson.
Microsoft Access Get a green book. Page AC 2 Define Access Define database.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Session 8: Databases Teaching Computing to GCSE Level with Python.
ATADESAB. BATLE CORDER DLEIF Lesson objectives In this lesson you will learn some basic database terms and learn how a database is created.
Database Systems Microsoft Access Practical #3 Queries Nos 215.
Microsoft Access 2010 Crash Course Part 1 Academic Health Center Training (352)
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
Database revision.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
Introduction to Access Chapter 13 pages 1-4. What is a database??? Related information is stored in databases  All SC student information is stored in.
Assignment 1 Uploaded to course website Due next Tuesday, Sep 1, at 11:59pm.
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
PGCE Computer Science/ICT Progression in Databases Alex Hadwen-Bennett.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Chapter 1. Getting Started IST 210: Organization of Data IST2101.
Database Presentation BIM, Mrs. Bailey. **Database Notes** Use new sheet of paper! Microsoft Access - known as a database management system or DBMS Database.
Database (Microsoft Access). Database A database is an organized collection of related data about a specific topic or purpose. Examples of databases include:
LEC-8 SQL. Indexes The CREATE INDEX statement is used to create indexes in tables. Indexes allow the database application to find data fast; without reading.
PGCE Computer Science/ICT Progression in Databases Alex Hadwen-Bennett.
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
SQL SQL Ayshah I. Almugahwi Maryam J. Alkhalifa
GCSE COMPUTER SCIENCE Data 2.2 Characters and Images.
DBMS and SQL.
Query Methods Simple SQL Statements Start ….
3.5 Databases Relationships.
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Creating a Database Microsoft Access.
 2012 Pearson Education, Inc. All rights reserved.
GCSE COMPUTER SCIENCE Computers 1.1 What is a Computer?
Structured Query Language (SQL)
Database Concepts Relational Databases Start ….
Databases.
GCSE COMPUTER SCIENCE Topic 3 - Data 3.5 Databases.
CIS 336 strCompetitive Success/tutorialrank.com
Structured Query Language (SQL) William Klingelsmith
Chapter 8 Working with Databases and MySQL
GCSE Computing Databases.
Structured Query Language
Microsoft Official Academic Course, Access 2016
Database Management Concepts
CMPT 354: Database System I
Databases and Information Management
Introduction To Databases GCSE Computer Science
Databases.
Database Fundamentals
Introduction To Structured Query Language (SQL)
Introduction To Databases GCSE Computer Science
Queries.
A Very Brief Introduction to Relational Databases
GCSE COMPUTER SCIENCE Topic 3 - Data 3.11 Databases.
The University of Akron College of Applied Science & Technology Dept
Databases This topic looks at the basic concept of a database, the key features and benefits of a Database Management System (DBMS) and the basic theory.
Do it now – PAGE 8 You will find your do it now task in your workbook – look for the start button! Sunday, 12 May 2019.
Manipulating Data Lesson 3.
Presentation transcript:

GCSE COMPUTER SCIENCE Data 2.4 Databases & SQL

Are used to store structured data. Structured & Unstructured Data You need to be able to name some examples of structured and unstructured data. Unstructured Data Photos Presentations Videos Documents Structured Data Phone Book Address Book Customer Details Train Timetable Databases Are used to store structured data.

Key Terms Field One piece of information. Record All of the data or information about one item. Primary Key A unique identity for each record. Table Stores all of the information about one particular category. Student_ID First_Name Last_Name Address DOB Gender 1 Peter James 310 Brook Lane 21/05/1985 Male 2 Tony Jackson 7 Somerset Avenue 15/12/1992 3 Sarah Jones 35 West End Road 6/08/1980 Female ACTIVITY Write the three key definitions in your exercise book.

Activity 1 Can you find an example in this database showing a primary key, field, record and table? Primary Key ID Name Breed Gender Date_Of_Birth Enclosure Capacity Headkeeper C009 Toni Tiger Male 30/6/1982 Big Cats 12 J Milner C015 Andrew Lion Female 18/6/2009 A007 Chimpy Chimpanzee 19/7/2011 Ape House 50 S Larkin Record Table Field

Turn the A4 sheet into a revision poster by: Activity 2 Instructions Cut out the table and stick it in the middle of a page in your book. Write in the elements and group them to form records for each video game. Turn the A4 sheet into a revision poster by: Adding ‘Databases’ as the title Labelling the primary key and writing a short definition of the term. Labelling a field and writing a short definition of the term. Labelling a record and writing a short definition of the term. Labelling the table and writing a short definition of the term.

Correct Groups Game ID Title Platform Genre Release Date 01 Pacman Arcade 1980 02 Halo Xbox First Person Shooter 2001 03 Minecraft PC Survival 2009 04 Wii Sports Wii Sports 2006 05 Super Mario Bros. NES 1985

Write this in formation about relational databases in your book. Relational Databases split data across different tables to reduce duplication. A foreign key is used to link tables together and create a relationship between them. Student_ID First_Name Last_Name Address DOB Gender Class_ID Student_ID Subject Teacher_ID A foreign key is a field in one table that is linked to a primary key in another table. ACTIVITY Write this in formation about relational databases in your book.

Activity 3 How could this table be split into two linked tables called Animal and Enclosure? Write down the field names that should go in each table. ID Name Breed Gender Date_Of_Birth Enclosure Capacity Headkeeper C009 Terry Lion Male 30/6/1982 Big Cats 12 J Milner A019 Sam Gibbon Female 10/6/2002 Ape House 50 S Larkin C015 Toni Tiger 18/6/2009 B033 Bob Red deer 6/7/2007 Deer Park 200 A Hunt A007 Charlie Chimpanzee 19/7/2011 ANSWER ANIMAL Table: ID, Name Breed, Gender Date_of_Birth, Enclosure. ENCLOSURE Table: Enclosure, Capacity, Headkeeper.

Activity 4 Re-organise the data from the Zoo table in Activity 2 in to two linked tables called Animal and Enclosure.

Activity 4 Answer ID Name Breed Gender Date_of_Birth Enclosure C009 Terry Lion Male 30/6/1982 Big Cats A019 Sam Gibbon Female 10/6/2002 Ape House C015 Toni Tiger 18/6/2009 B033 Bob Red Deer 6/7/2007 Deer Park A007 Charlie Chimpanzee 19/7/2011 Enclosure Capacity Headkeeper Big Cats 12 J Milner Deer Park 50 S Larkin Ape House 200 A Hunt

SQL = < > <= >= <> Structured Query Language is the language used to search databases. You need to be able to read and write simple SQL statements. The following comparison operators are used in SQL statements: Comparison operator Symbol Equal to = Less than < Greater than > Less than or equal to <= Greater than or equal to >= Not equal to <> Apart from equal to and not equal to they are the same as Python.

Here is an example SQL statement SQL Statements Here is an example SQL statement SELECT First_Name from Student WHERE Gender=“Male” Fields to show The table Search criteria This statement selects the First_Name from the Student table and only shows the Male students. Student_ID First_Name Last_Name Address DOB Gender 1 John Curtis 12 Brook Lane 21/03/1990 Male 2 Ben Jackson 1 Totters Lane 15/04/1990 3 Sarah Smith 60 Belsize Rd 6/06/1990 Female First_Name John Ben

SQL Commands Command Description Deletes rows from a database table. DELETE FROM TableName WHERE condtion Deletes rows from a database table. CREATE TABLE TableName (FieldName data type, …) Creates a database table. INSERT INTO TableName VALUES (Value, …) Inserts row into a database table. SELECT (FieldName, …) FROM TableName WHERE condition ORDER BY (FieldName, ..) Retrieves data from a table. The asterisk (*) can be used if all columns are required in the output. FROM Table1Name, Table2Name, … WHERE join criteria Retrieves data from two related tables. UPDATE TableName SET (FieldName=Value, …) Updates rows in a database table.

Included in search results Not included in search results SQL Practical: Instructions Several volunteers are needed! Each of you is a record in a database called Students. For each query displayed you will go to one side of the room. Go to the left if your record would be included in the query results and to the right if your record wouldn’t be included in the query results. Included in search results Not included in search results

Included in search results Not included in search results SQL Practical Included in search results QUERY 1 Not included in search results SELECT * FROM Students

SQL Practical SELECT * FROM Students WHERE HairColour = “Blond” Included in search results QUERY 2 Not included in search results SELECT * FROM Students WHERE HairColour = “Blond”

SQL Practical SELECT * FROM Students WHERE EyeColour = “Blue” Included in search results QUERY 3 Not included in search results SELECT * FROM Students WHERE EyeColour = “Blue”

SQL Practical SELECT * FROM Students WHERE EyeColour = “Brown” Included in search results QUERY 4 Not included in search results SELECT * FROM Students WHERE EyeColour = “Brown” ORDER BY FirstName

Included in search results Not included in search results SQL Practical Included in search results QUERY 5 Not included in search results SELECT * FROM Students WHERE BirthMonth > 7 ORDER BY Height

SQL Practical SELECT * FROM Students WHERE BirthMonth <= 5 Included in search results QUERY 6 Not included in search results SELECT * FROM Students WHERE BirthMonth <= 5 ORDER BY FirstName DESC

SQL Practical SELECT * FROM Students Included in search results QUERY 7 Not included in search results SELECT * FROM Students WHERE HairColour = “Brown” or HairColour = “Black” ORDER BY FirstName DESC

SQL Practical SELECT * FROM Students Included in search results QUERY 8 Not included in search results SELECT * FROM Students WHERE HairColour = “Black” and EyeColour = “Brown” ORDER BY LastName DESC

Link: https://www.codeschool.com/courses/try-sql Activity 5 Sign up for a free Code School account and complete the Try SQL course. Link: https://www.codeschool.com/courses/try-sql

Use this table to help you answer the following activities. Marksheet Table TABLE 1 Use this table to help you answer the following activities. Name Assign1 Assign2 Assign3 Average Aisha 51 60 64 58 Katharine 75 76 48 70 Fiona 100 87 72 86 Gareth 65 69 73 Jo 38 52 44 45 Manjit 66 68 Ian 13 17 26 19 Michael 43 33 40 Ubaid 55 50 53 Simon Mark 25 15 Gemma 78

Activity 6 Question Answer v v v v USE TABLE 1 SELECT Name FROM Marksheet WHERE Assign1=0 Mark SELECT Name FROM Marksheet WHERE Assign1>80 Fiona Gareth SELECT Name , Average FROM Marksheet WHERE Assign1<=30 Ian, 19 Mark, 13 Display the Name and Average of all the students that scored 60 or above in Assign3. SELECT Name, Average FROM Marksheet WHERE Assign3 >= 60 Display the Name and Average of all the students that scored less than 40 Assign2. SELECT Name, Average FROM Marksheet WHERE Assign2 < 40 Display the Name and Average of all the students that did not score 40 in Assign1. SELECT Name, Average FROM Marksheet WHERE Assign1 <> 40 v v v v USE TABLE 1

Use this table to help you answer the following activities. Food_Item Table TABLE 2 Use this table to help you answer the following activities. Product_Code Product_Name Price Supplier_Code Quantity_In_Stock 1239T Baked beans 0.34 S121/A 154 1237T Tomato soup 0.56 450 1309T Spaghetti hoops 0.80 99 4550F Oven chips 1.24 S234/F 550 3444F Fish fingers 1.45 756 2121G Frankfurters 1.02 S009/C 52 5544C Sausage rolls 2.45 S100/C 150

Search (also called a Query) Activity 7 Task Search (also called a Query) Write the SQL command to insert a new record into Products table, for a product with these details: Product_Code: 5500C Product_Name: Pork pie Price: 2.45 Supplier_Code: S100/C Stock: 150 INSERT INTO Products VALUES (5500C, Pork pie, 2.45, S100/C, 150) Write the SQL command to update the record for Tomato soup, the Quantity_In_Stock is now 415. UPDATE Products SET (Quantity_In_Stock = 415) Write the SQL command to delete the Oven chips record from the Food_Item Table. DELETE FROM Products WHERE (Product_name = Oven chips) Write the SQL command to delete one more record of your choice from the Food_Item Table. v v v USE TABLE 2

puzzle maker criss-cross Activity 8 Crossword Create a crossword based on this topic using the online crossword generator linked below. It should have a minimum of 10 questions. When you have finished, paste your crossword on to a Powerpoint slide and name it Databases & SQL. Print out one copy (include your name) and stick it in your book. http://puzzlemaker.discoveryeducation.com/CrissCrossSetupForm.asp puzzle maker criss-cross