3.7 Relational Databases and SQL Flashcards
What is a database?
A database is a persistent collection of organised storage that can be retrieved through queries
What is SQL?
Structured Query Language
What is data redundancy?
Duplicate pieces of data
What is data inconsistency?
Storing repeated data in the same table can lead to inconsistencies in the data
Range check
A number or date is within a sensible/allowed range i.e. Month between 1 and 12
Type check
Data is the right type
Length check
Text entered is not too long or too short - for example a password is between 8 and 15 characters
Presence check
Checks that the data has been entered, i.e. The field has been left blank
Format check
Checks the format is correct, for example, a postcode or email is correct
List check
Making sure the user enters the right thing from a list. They can only select an option from a drop-down menu.
What wildcard is used to represent everything?
*
SQL SELECT
Select *
FROM table1
SQL WHERE
Select *
FROM table1
WHERE Forename = ‘Bob’
- If the value is a string (or varchar, text etc.) then it requires quotation marks.
SQL SELECT SORTING
Select Forename, Surname
FROM table1
ORDER BY Surname ASC
- ASC = Ascending
- DESC = Descending
SQL INSERT
INSERT INTO table1 (userId, Forename, Surname, Age, Height, MobileNumber)
VALUES (1, ‘Bob’, ‘Jones’, 47, 1.87, ‘07834 577780’)
- If the value is a string (or varchar, text etc.) then it requires quotation marks.