AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Keys, types and forms

Week 18 · Unit 7.4: The power of data · 3 lessons
2

A dictionary for your data

Computing 7: Unit 7.4, pp. 112–149
GoalChoose a data type and a sensible field length for each field, and record the choices in a data dictionary.
New words
data type · the kind of data a field can store, such as text, number or datefield length · the largest number of characters a text field may holddata dictionary · a table that lists each field’s name, data type and length when a database is designedcurrency · a data type for amounts of money
Explanation

Every field must have a data type, because the type decides what the computer can do with the data. Text holds letters, digits and symbols that are not used in calculations. A phone number is Text, because you never add phone numbers and a number would lose its first zero. Number holds values you may calculate with, Currency holds money, Date/Time holds dates and Yes/No holds only two values. Autonumber counts up by itself. Text fields also get a field length: a database program usually sets aside 255 characters, so designers choose a shorter length to save space. Designers list all their choices in a data dictionary before they build the table.

Field nameData typeField lengthKey
AnimalIDAutonumber–*
NameText20
SpeciesText15
AgeNumber (whole)–
DateArrivedDate/Time–
FeeCurrency–
VaccinatedYes/No–
Worked examples
Sample valueBest data typeWhy
0555 0123Texta phone number; no calculations; keeps the first 0
11Numbercan be added or compared
12/03/2025Date/Timea date
25.50Currencyan amount of money
YesYes/Noonly two possible answers
The animal shelter’s data dictionary above has one line for each field. The star shows the primary key, and a length is only needed for text fields. This table shows how sample values are matched to data types.
FieldLongest value expectedCharactersLength chosen
NameBartholomew1120
Specieschimpanzee1015
CodeANI-0042810
Choose the length by thinking about the longest value that might be typed, and then add some room. Names longer than 20 letters are rare, so 20 is a sensible length for a pet’s name. A length of 255 would waste space in a big table with thousands of records.
Age as Number, sortedAge as Text, sorted
210
52
95
109
The data type also decides what you can do. You can ask the database for all animals older than 5 only if Age is stored as a number. If Age were Text, 10 would be sorted before 9, because text is sorted letter by letter and the character 1 comes before 9.
Class activity

My collection dictionary (no computer). Choose something you or your family collect or keep a list of, such as books, stamps, plants or football cards. On paper write a data dictionary with at least six fields: a field name, a data type and a field length for the text fields. Add a star to the primary key. Then write three sample records and check each value: does it fit the type? Does the text fit in the length? Swap with a partner, who must find one field that could be improved and say why.

Practice
1
Here is one record of a seed table. Choose the best data type for each field.
PacketIDPlantDaysSow byPriceOrganic
7Sunflower9014/03/20251.20Yes
2
A designer chose Number for a phone-number field. Ali types 0555 0123 and the database stores 5550123. What went wrong, and which data type should be used instead?
3
This data dictionary has some poor choices. Find three of them and say how to fix each one.
Field nameData typeField length
NameText255
AgeText3
CostNumber–
JoinedText10
4
On paper write a data dictionary for a table that records the trips of a school bus. Use at least five fields, mark the primary key with a star and give a length for each text field.