Objectives

Students will be able to:

  • user AND and OR to create more complex queries
  • group records depending on criteria
  • possibly produce a simple chart - software integration awareness

Query Keywords - AND/OR

Data miners scrape data off webpages!

They then analyse the data by creating queries. Using the results they will produce reports, for the benefit of anyone who will them, I suppose.

Queries depend on criteria. Often we can identify multiple criteria to extract a set of records from a database.

For example, imagine we have the following table:

criteria
or

Run a query that will show all records of people from UK OR USA.

   Skill-up 1 - and/or

Download the csv file about social network users. Save it in a project folder.

Import the data into a XAMPP database table. There should be 7 fields and 28 records.

Remember to ask yourself a couple of questions:

  1. Does the first row contain field names?
  2. Is there a field which makes every record unique? If not, add a new field called id which auto-increments.

Video Task

Watch the video and answer the questions in the worksheet.

Query 1

Research how to use the operator in SQL to solve the following query:

select all records where people are from the UK or the USA

Tip! If you click on a field name on the right side of the screen when designing queries, it will save time and reduce spelling mistakes!

    Challenge 1 - More complex queries

Design-Test-Redesign the following queries.

Hint! Your queries should produce the same number of records as indicated.

select all people living in Singapore who like noodles or HBO movies.2 records
select all records where users are 18 or 28 or 38 and love peperoni pizza.1 record
select all records where users from UK, USA and Canada are sports lovers. It is sorted in order of location.4 records

Paste a screenshot of the query in the worksheet document where indicated.

    Challenge 2 - A chart

Using the data from the last query and any other technology, create a pie chart clearly showing the number of people from UK, USA and Canada who like sports.

    Challenge 3 - A report

Write a short report explaining the results of your data analysis.

Your report should include a screenshot of your chart and be formatted as follows:

  • document: landscape orientation
  • title: Music Lovers, font-size 48, centre-aligned
  • subtitle: by your name, font-size 24, right-aligned
  • body text: double line spacing, 2 equal columns
  • screenshot: should have a thin, light gray border.

Here is the body text to include in the document.

Submission

Submit your document in pdf format along with your worksheet.

Food For Thought

And and Or are magical words in Database Technology. They allow you to create more complex queries. Experience will teach you how to use them properly.

Homework




essential vocabulary

database querycriteriaimport evidence table integer screenshot record text ascending field double descending data type Yes/No


SUBSCRIBE

Join my mailing list to receive updates on the latest blog posts and other things.