Presentation is loading. Please wait.

Presentation is loading. Please wait.

Queries.

Similar presentations


Presentation on theme: "Queries."— Presentation transcript:

1 Queries

2 Let’s play a simple game
I am an animal what animal am I? Write the name of something on the post it note Swap with your partner Try and guess by asking YES / NO question what you are You can only answer YES or No

3 Today’s Learning Objective
Create a Form and add controls Understand the use of Logical Operators in framing database Queries Saturday, 06 April 2019

4 Remember Solving those crimes John?

5 What you need to know ○ simple criteria, i.e. = ○ complex criteria, i.e. <, >, <>, >=.<=, NOT, AND, OR, BETWEEN ○ sort data

6 Searching for a Matching Criteria Parameter Query [ ] And Query
Four Queries Searching for a Matching Criteria Parameter Query [ ] And Query Or Query How to Sort results How to create a Query

7 What is a Database A database is : “An organised collection of related data that is stored and convenient to use and access” It contains data, (raw facts and figures) but because it is organised in a logical order the data becomes information that can be searched and used to create new information It consists of tables, forms, reports and queries

8 Application /software
The DBMS sits between the database and the software application used to access the database User Application /software DBMS Database

9 What is a DBMS? DBMS: stands for Database Management System If you want to access a database form a web page, an app, you phone then it requires software that will organise the security, storing and retrieval of the data. A DBMS communicates between the database and the interface that the user sees User interactivity is achieved through use a command language (SQL)

10 What can a DBMS do True or False
Create a new Database Create new table, record Update the database records and fields Delete, the database, individual records, Produce new data using queries and produce reports Manage the security of the data

11 Separating data from applications
The DBMS that the DBMS software sits between the database and the applications that run it. Why separate them? Separation is a strength because, A webpage or application could be redesigned without the concern of redesigning the database The database can be redesigned or modified without concern hat the application has to be redesigned. Other businesses or developers can create or customise their own DBMS for a database

12 Data Base Administrator
A Database Administrator has responsibility of managing and organising the database to ensure that it is in working order. They have to ensure that the data is structured and organised in an appropriate manner to meet the needs of the users. They also make sure that the database is backed up and that the data is kept secure through passwords and encryption

13 True or False DBMS means Data Based Management System
DBMS are Databases A user can access the database through the DBMS DBMS can be used to search for records in the database? A DBMS can be changed without it editing the database? A database administrator is responsible for the DBMS? A database administrator is responsible for the security of the database DBMS can be used to edit a database? DBMS can be used to create graphs of the data

14 True or False Answers DBMS means Data Based Management System (F)
DBMS are Databases (F) A user can access the database through the DBMS (T) DBMS can be used to search for records in the database? (T) A DBMS can be changed without it editing the database? (T) A database administrator is responsible for the DBMS? (F) A database administrator is responsible for the security of the database (T) DBMS can be used to edit a database? (T) DBMS can be used to create graphs of the data (F)

15 SQL STATEMENTS The DBMS application and the database need to communication with each other to allow the user to mange the database SQL allows a user to control and send instructions to a database SQL stands for Standard Query Language, it allows the application to speak to the database and organise and manage it The next few slides will cover the statements to insert a record, delete a record and how to search for particular data and records

16 SQL CREATE A NEW RECORD SQL allows the user to create a new record in the database via the DBMS INSERT INTO Customers VALUES (‘Sarah', ‘Jones', ‘UK') INSERT INTO Customers instructs the DMBS to Insert a new record into the customer table VALUES (‘Sarah', ‘Jones', ‘UK') tells the application the values Sarah Jones and UK are being added to the table

17 SQL Delete If you want to delete a record you can use the delete command DELETE FROM Customers WHERE CustomerName=‘Smith' AND ContactName=Jones‘ This would delete the records Smith and Jones

18 SQL RETRIEVING RECORDS
This statement instructs the DBMS to select all the records from the customer table SELECT * FROM Customers; SELECT : Tells the program you want to select the records without changing them * the star represents all the records FROM Customers: this TELLS THE DBMS to select all the records from the customer table

19 SQL WHERE What if you want to find a particular piece of data from a particular field? SELECT * FROM Customers WHERE Country=‘UK'; Where = ‘UK’,: tells the database to only return THE records where the condition is met, the country is UK. This would find and return all the customer records that have the Country listed as UK

20 SQL AND QUERY What if you want to find a particular piece of data from a field and data from another field? SELECT * FROM Customers WHERE Country= ‘UK' AND City=‘London'; SELECT * FROM Customers means select all the records from the customer table WHERE Country= ‘UK‘ select the records where the field country is UK AND City=‘London'; and the records where the City field is London

21 SQL OR QUERY When using the AND search criteria, SQL will return the records where, both field values are met. To search for return records where the Country is UK OR the City is London. SELECT * FROM Customers WHERE Country= ‘UK' OR City=‘London'; The OR statement returns records where either the Country is UK or the city is London

22 GAME TIME FROM SELECT, *, Customers, Country= ‘UK‘, WHERE AND, City=‘London'; SELECT, FROM, ‘ ', BankDetails, *, WHERE, = ‘0234‘, OR, Account SortCode = Which statement is used to select all records?, SELECT ALL, SELECT * ALL, SELECT * FROM What is missing from this statement to delete a record? ……the Customers WHERE CustomerName=‘Smith' AND ContactName=Jones‘ DELETE, DELETE FROM, DELETE WHERE, DELETE WHEN, SELECT, *, FROM, Customers, WHERE, Country= ‘UK‘, AND, City=‘London'; What command do you use to find a record that contains either one of two pieces of data? OR, EITHER, ELSE, AND

23 GAME TIME answers SELECT, *, FROM, Customers, WHERE, Country= ‘UK‘, AND, City=‘London'; SELECT, *, FROM, BankDetails, WHERE, Account= ‘0234‘, OR, SortCode =‘ ', SELECT * DELETE FROM, OR, EITHER, ELSE, AND


Download ppt "Queries."

Similar presentations


Ads by Google