Question 1
16 marks
Sand dune ecological survey database, data types, validation, ERD, composite keys, and SQL
- Databases
(a)(i)
1 mark
`String` / `Text` (or `VARCHAR` / `Alphanumeric`).
Mentor tip
Plant species names (like 'Marram grass') consist of alphabetic characters and spaces, requiring a text/string data type.
(a)(ii)
1 mark
`Real` / `Float` (or `Numeric` / `Double`, since site gradients include decimal values such as `8.2` and `7.9`).
Mentor tip
Check Figure 2 (`Site` table) where `Gradient` values are decimals like `8.2`, making `Real`/`Float` the most accurate choice.
(b)
2 marks
- Apply a range check on the `Gradient` field to ensure the entered slope angle falls within a valid physical interval (for example, between `-90` and `+90` degrees, or `0` to `90` degrees).
- Alternatively, apply a numeric type check to reject non-numeric characters or a presence check to ensure the field is not left blank.
Mentor tip
Name a specific validation check (range check, type check, or presence check) and state the exact rule applied to `Gradient`.
(c)
3 marks
- 1. Include all three entities: `Plant`, `Distribution`, and `Site`.
- 2. Draw a one-to-many () relationship from `Plant` to `Distribution` (one plant species can be recorded across many distribution survey entries).
- 3. Draw a one-to-many () relationship from `Site` to `Distribution` (one dune site can host many plant distribution records):
- `Plant (1) ----< (M) Distribution (M) >---- (1) Site`
Mentor tip
`Distribution` acts as an associative/junction table resolving the many-to-many relationship between `Plant` and `Site` into two 1-to-many relationships.
(d)
2 marks
- Neither `Plant_ID` nor `Site_ID` (nor `Date`) is unique on its own in the `Distribution` table because multiple plant species grow at the same site and the same site is surveyed on multiple dates.
- Combining `(Plant_ID, Site_ID, Date)` into a composite primary key uniquely identifies each survey observation without needing to add a redundant surrogate ID column.
Mentor tip
Explain both why single fields repeat in `Distribution` and how combining them uniquely identifies each row while saving storage.
(e)
4 marks
- 1. Identify the tables required: `Plant` and `Distribution`.
- 2. Join the two tables on their common key: `Plant.Plant_ID = Distribution.Plant_ID`.
- 3. Filter for `Plant.Species = 'Gorse'` AND `Distribution.Date = '14/10/2019'`.
- 4. Apply the aggregate function `COUNT(Site_ID)` to return the total number of matching sites:
- `SELECT COUNT(Distribution.Site_ID) FROM Plant INNER JOIN Distribution ON Plant.Plant_ID = Distribution.Plant_ID WHERE Plant.Species = 'Gorse' AND Distribution.Date = '14/10/2019';`
Mentor tip
Ensure your query steps include the table join on `Plant_ID`, both filter conditions (`Species` and `Date`), and the `COUNT` aggregation.
(f)
3 marks
- 1. Enforce referential integrity constraints and cascading updates/deletes so that every `Plant_ID` and `Site_ID` foreign key in `Distribution` must correspond to an existing primary key in `Plant` and `Site`.
- 2. Keep the schema normalized (3NF) to eliminate duplicate data across tables, and wrap data modifications in atomic transactions with input validation rules so partial or invalid updates are rolled back.
Mentor tip
Mention referential integrity (foreign key constraints), cascading updates, normalization, and transactional atomicity/validation.

