- Which data type should a telephone number use?
- A telephone number should be text or alphanumeric. It has a leading zero and spaces, so integer is unsuitable. It is never used for calculations, so it is stored as alphanumeric data even though it contains digits.
- When should a field be integer, decimal or currency?
- Use integer for a whole number, such as a count of items in stock. Use decimal when a value is not necessarily a whole number. Use currency when the field must display the currency symbol, because a decimal type would not display it.
- How should a database store a person's age?
- Store the date of birth in a date and time field, and calculate the age. Age changes every year, so it is dynamic and a fixed value would go out of date. Age is today minus the date of birth, because subtracting the year of birth ignores the day and month.
- What does a data dictionary contain?
- A data dictionary specifies the structure of a database and is laid out as a table. For each field it records the field name, the data type with the sub-type for numeric data, the field size for alphanumeric data, whether it is the key field, and a validation rule to reduce data entry errors.
- How should field names be written in a data dictionary?
- Field names and table names should have no spaces, and should use snake case or camel case. A field holding two pieces of data, such as a full name, should be split into atomic fields such as forename and surname. Give field sizes to alphanumeric fields only, not to numeric fields.
- Why do answers about data types lose marks even when the type is right?
- Many responses identified text as the answer but did not give a reason why an alternative data type would be unsuitable. Give the reason: for a telephone number, the leading zero and spaces rule out integer, so the reason must be given with the type.