0% found this document useful (0 votes)
3 views7 pages

Past paper for physics

Past paper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Past paper for physics

Past paper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Single Table Databases

• A database is a structured collection of data so it can be searched, sorted,


filtered and analysed quickly
o Data in a database can be any type of data including text, images,
videos, sound
• Databases use tables to store data
• Tables have records of data represented by one row
o In the example below, each row represents the data stored about a
single customer (the customer’s record)
o In the customer table there are 3 records
o Each record is divided into fields (CustomerID, FirstName, LastName,
DOB and Phone Number)
• Fields are represented by the columns in a table
o There are 5 fields in the customer table
o The first row in a table contains the field names which is the heading
for the data stored in that field
o Each field in a table has a data type which defines what data can be
entered into that field

Validation and Verification


• Verification checks check whether the data that has been entered is
the correct data and is accurate
o This is often completed by getting data entered by one person is then
checked by another person
• When a table is created, validation rules can be assigned to the different
fields
o A validation rule controls what data can be entered into that field
o There are different types of validation checks used to limit what data
can be entered into each field
The different types of validation check

Data Types
• Table fields are represented by columns in a table
• There are 5 fields in the customer table below
o These include CustomerID, FirstName, LastName, DOB and
PhoneNumber

• Each field in a table, has a data type


o Common data types include text/alphanumeric, character, boolean,
integer, real and date/time
o Phone numbers have to be assigned the text/alphanumeric data type
because they begin with a 0
▪ If you assigned the data type Integer to a phone number it would
remove the initial 0
Primary Keys
• Each table has a primary key field which acts as a unique identifier
o Each item of data in this field is unique
o Duplicate data items would be blocked if they were entered into the
primary key field
• Because the items of data are unique within the primary key field they can be
used to identify individual records

A Database Table Containing Customer Details

• In the example customer table, the primary key would be


the CustomerID because each customer’s ID is unique
• If there was a customer with the same name they could be identified correctly
using the CustomerID

SQL
• Records in a database can be searched and data can be manipulated
using Structured Query Language (SQL)
• SQL statements can be written to query the data in the database and extract
useful information
• SQL statements follow this structure:
o SELECT the fields you want to display
o FROM the table/tables containing the data you wish to search
o WHERE the search criteria

Example

SELECT Name, Rating

FROM Movie

WHERE Rating>8.4;

The results of this query would be:

• The two fields - Name and Rating have been extracted from the Movie table
and then the records have been filtered by Rating
• This example uses the > operator to search for records where the rating
is greater than 8.4
• There are several other comparison operators which can be used to create
the filter criteria in the WHERE line of a SQL query
Example

SELECT Name,Rating

FROM Movie

WHERE Genre=”Family” AND Certificate=”U”;

The results of this query would be:

• The two fields Name and Rating have been extracted from the Movie table
and the records have been filtered by both Genre and Certificate
• This query uses the AND logical operator to include multiple criteria in the
WHERE line of the SQL query
• Another logical operator which can be used in the WHERE statement is OR
o For example, WHERE Genre=”Comedy” OR Genre=”Family”

ORDER BY
• You can enter a fourth line to the statement using the ORDER BY command,
followed by ASC or DESC
o If you enter ASC the results of the query will be sorted
in ascending order
o If you enter DESC the results of the query are sorted
in descending order
Example

SELECT Name,Genre, Certificate, Rating

FROM Movie

ORDER BY Name ASC

• The results of this query would be:

• The query has returned four fields and all records because there were no
WHERE criteria. The records are sorted by Name alphabetically
o If numbers are sorted in ascending order they go from the lowest
number at the top of the table to the highest number at the bottom
o Descending order is the highest number to the lowest

SUM and COUNT commands


• The SUM command can be used to add numerical data
• The COUNT command can be used to count items of data

Example

SELECT SUM(QuantityInStock)
FROM ProductTable;

• This query will add up all of the numbers in the QuantityInStock field
o The result of this query would be 25

Example

SELECT COUNT(*)

FROM ProductTable

WHERE Price>2;

• This query will count all the records with a price greater than 2
o The result of this query would be 3
o This is because there are three products with a price greater than £2
(Chips, Beans, Bananas)

You might also like