What is an entity?
An entity is the object / thing of interest about which data is to be recorded (a table in SQL).
What is an attribute?
An attribute is property of an entity (a field in SQL).
What is a relationship?
A relationship is the link or association between entities (primary keys ←→ foreign keys)
What is a key (in a database)?
What is a primary key?
A key which has a unique value for each record, and acts as a unique identifier for each record
3 problems with a flat file database
How do you solve the problems with flat file databases?
What is a flat file database?
A simple store of information
- Columns are called fields
- Rows are called records
- A table is a group of records
What is a composite key?
A key composed of two or more attributes that together uniquely identify a record.
When is normalisation (database) achieved?
What is the saying for database normalisation?
“Each attribute must depend on the key, the whole key, and nothing but the key”
Requirements for 1st normal form
What is a repeating group?
A set of attributes whose structure repeats between rows
Requirements for 2nd normal form
No partial dependencies
this means…
- Do all nonkey attributes depend on all parts of the composite key?
- If not, take them out and create a new entity.
(So check all tables with composite keys)
Requirements for 3rd normal form
No non-key dependencies
- All non-key attributes are checked to see if they are only dependent on the primary key.
How do you identify the key in an entity relationship diagram?
Underlining
SQL: Create a database called school
CREATE DATABASE school
What does DDL stand for (in SQL)?
Data Definition Language
SQL: Create a table called students
(StudentNumber as primary key, forename, surname, and date of birth)
CREATE TABLE students
(
StudentNumber INT(8) PRIMARY KEY,
forename VARCHAR(32),
surname VARCHAR(32),
DateOfBirth DATE
)
SQL: What is the keyword for deleting a database/table?
DROP …
SQL data types
CHAR(size) // → fixed length stringVARCHAR(size) // → string (with a maximum length)ENUM // → string object that has to be chosen from a list of possible valuesBOOL / BOOLEANINT(size) // → size is the number of digitsFLOAT(size,d) // → size is the number of digits , with d digits after the decimal pointDATETIMEDATETIME
What does DML stand for (in SQL)?
Data manipulation language
SQL: all strings beginning with ‘str’
LIKE ‘str%’
SQL: Any strings at least five characters long
LIKE ‘_____%’