9 Databases Flashcards
What are the 6 database datatypes you need to know?
- Integer: whole number
- Real: decimal number
- Text: sequence of characters
- Character: single character
- Date/Time -
- Boolean - one of 2 values e.g. Yes/No, True/False
What is a field?
One piece of information about an object e.g. student name (column)
What is a record?
A collection of fields about the same object e.g. one student (row)
What is a table?
A collection of records about the same entity e.g. students
What is a primary key?
A field that uniquely identifies each record. No duplicates e.g. StudentID
What is a database?
A persistent and structured collection of data
How many fields are in the table?
How many records are in the table?
How many fields are in the table? 5
How many records are in the table? 8
Which field is suitable as a primary key and why?
Show Number because it uniquely identifies each show/record
State an appropriate data type for the field Date
State an appropriate data type for the field Sold out
State an appropriate data type for the field Show Number
State an appropriate data type for the field Date: Date
State an appropriate data type for the field Sold Out: Boolean
State an appropriate data type for the field Show Number: Text
Which field is suitable as a primary key and why?
PCID because it uniquely identifies each stock item/record
State an appropriate data type for the field PCID:
State an appropriate data type for the field Screen Size:
State an appropriate data type for the field Price:
State an appropriate data type for the field PCID: text
State an appropriate data type for the field Screen Size: Integer
State an appropriate data type for the field Price: Real
An SQL SELECT statement is used to retrieve data that meets a specified criteria from a database table. The data may also be sorted in ascending or descending order. What are all of the key words used in an SQL SELECT statement?
SELECT Flight_Code, Flight_Name
FROM FLIGHTS
WHERE Flight_Duration > 14 AND
Flight_Duration < 17
ORDER BY Flight_Name DESC
Retrieves the flight code and flight name from the table where the flight duration is 15 or 16 hours and sorts the data in descending order by Flight Code
SUM can be used as part of a SELECT statement to find the sum of all the values that meet a specified criteria. How is it used?
SELECT Sum(Flight_Duration)
FROM FLIGHTS
WHERE Flight_Name = “Emirates”
Calculates the sum of the flight durations or all Emirate flights
COUNT can be used as part of a SELECT statement to count the number of records that meet a specified criteria. How is it used?
SELECT Count(Flight_Duration)
FROM FLIGHTS
WHERE Flight_Duration < 17