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

Fields and records

Week 16 · Unit 7: Be a data boss · 3 lessons
3

Four data types

Computing 4: Unit 7, pp. 90–103
GoalName the four data types and choose the right data type for a field.
New words
data type · the kind of data that a field can storenumber · a value that you can count or calculate withdate/time · a date or a time of dayyes/no · a field that can hold only “Yes” or “No”
Explanation

Every field has a data type. The data type tells the computer what kind of data the field may hold. Text can hold letters, digits and symbols, such as a name or a phone number. Number holds numbers that we can add, count and compare, such as a weight. Date/Time holds a date or a time. Yes/No holds only the word Yes or the word No. A phone number is text, because nobody adds phone numbers and many start with 0 or +. Calculations only work on the type Number. The data type of a field stays the same for every record.

FieldExampleData type
NamePipText
SpeciespenguinText
Date born12/03/2019Date/Time
Weight (kg)6Number
Plant eaterNoYes/No
Worked examples
FactAdd two of them?Data type
weight in kgyes, for a total weightNumber
goals scoredyes, for a totalNumber
phone numberno, it makes no senseText
postcodenoText
Can we calculate with it? That is a good test for the type Number.
Data enteredField typeAllowed?
MaybeYes/Nono
8Numberyes
eightNumberno
12/05/2022Date/Timeyes
A field only accepts data that matches its type. A computer will refuse the wrong data.
FieldData type
Player nameText
Goals this yearNumber
Date joinedDate/Time
Is captainYes/No
A table about a football club needs all four types. Each field has the data type that fits.
Class activity

Type sort (with family): write ten facts on small cards, for example a first name, a shoe size, a birthday, “Do you like swimming? Yes”, your age, a favourite colour, the time you get up, the number of books you own, a street name and a postcode. Make four piles: Text, Number, Date/Time and Yes/No. Which card was hardest to place? Why? Check each card in the Number pile: would it make sense to add two of them?

Practice
1
Choose the data type for each field: Text, Number, Date/Time or Yes/No.
FieldData type
A Pet name?
B Goals scored?
C Birthday?
D Has a bike?
E Phone number?
2
Which of these can be entered in a field of the type Number: 12, 12.5, twelve, 12 cm?
3
Why can you not do calculations with the data type Text?
4
A zoo keeper wants to store whether each animal has seen the vet this year, and how many times. Name the two fields she needs and give each one a data type.