Primary Keys (PK): A primary key is a unique identifier for every record in a table. It must be unique for every row and cannot be null, ensuring that every individual entry can be precisely targeted for retrieval or updates.
Foreign Keys (FK): A foreign key is a field in one table that points to the primary key of another table. This creates the 'link' or 'relationship' between the two entities, allowing data to be joined across the database.
Structured Query Language (SQL): SQL is the standard language used to communicate with relational databases. It uses specific commands like SELECT to retrieve data, INSERT to add new records, UPDATE to modify existing ones, and DELETE to remove them.
| Feature | Flat File Database | Relational Database |
|---|---|---|
| Structure | Single Table | Multiple Linked Tables |
| Redundancy | High (Data repeats) | Low (Data stored once) |
| Maintenance | Difficult (Update many rows) | Easy (Update one row) |
| Complexity | Low | High |
Identifying Keys: When asked to identify a Primary Key, look for a field that is guaranteed to be unique, such as an ID number. Avoid using names or dates, as these can often be duplicated.
SQL Syntax Precision: In exams, pay close attention to the order of SQL clauses. The standard order is SELECT [fields] FROM [table] WHERE [condition] ORDER BY [field]. Swapping these will result in syntax errors.
The Power of Wildcards: Remember that the asterisk () selects all columns, while the percent sign () is used with the LIKE operator for pattern matching (e.g., LIKE 'A%' finds all values starting with 'A').
Safety First: Always check for a WHERE clause when writing UPDATE or DELETE statements. Without a WHERE clause, the command will apply to every single record in the table, which is a common exam trap.
Confusing Records and Fields: Students often swap these terms. Remember that a Field is a column (a single category of data), while a Record is a row (a complete set of data for one entity).
Null Foreign Keys: While a Primary Key cannot be empty, a Foreign Key can sometimes be null if a relationship hasn't been established yet. However, if it contains a value, that value must exist in the related table's Primary Key field.
Redundancy Misconception: Some believe that having a Foreign Key creates redundancy. In fact, storing a single ID number (the FK) is far more efficient than repeating entire sets of text data (like a full address or name) multiple times.