Download ict notes
Transcript
Section 5 Data Types When a database is designed, all the fields are set to accept a particular data type. This helps check for the wrong type of data being entered and makes sure the data is stored as efficiently as possible. It also means it will be sorted correctly. Alphanumeric/text - a field of this data type will accept both numbers and text. When to use - if you want to enter text or a mixture of text and numbers. When NOT to use - if you want to store only numbers or only dates. You can enter numbers or dates into text fields but they would get sorted as if they were words and could not easily be used for any calculations. Numeric - a field of this data type is used to store numbers. There are two types of numeric field you need to know about: Real - used for decimal numbers such as 3.4, 3.1427 and 6.0 etc. Real numbers can be formatted as currency (i.e. £5.67) or to a fixed number of decimal places (i.e. entering 3.1427 into a real number field formatted to two decimal places would mean it appeared as 3.14) When to use - if the field is going to be used to store numbers with decimal places such as 'height', 'length' etc. Integer - used for whole numbers. When to use - if the field is only going to be used to store whole numbers, i.e. 'number of children', 'car doors' etc. Logical/Boolean - a field of this data type will only let you enter a 'Yes' or a 'No'. This may be as text (YES/NO or TRUE/FALSE) or as a tick/blank. When to use - when you only need to store something as 'true' or 'false' or store whether something exists or does not exist. Date - this special field stores days, months and years so that records can be sorted correctly. Date fields can display the date information in different formats such as the full name of the day/month (28th August 1961) or the numerical versions (28/08/61) When to use - for any field which will be used to store date information. Examples of use: A football club uses a database to store details of its players. Data such as Surname and First name is stored in text fields. The players car registration is mixture of text and numbers so it is stored in a text field. The height of the player (in metres) is a decimal number so it is stored in a real number field. The number of goals scored is a whole number so it is stored in an integer number field. The player's date of birth (DOB) is a date so it is stored in a date field. The players telephone number has a space between the code and the actual number so it is stored in a text field. Information such whether the player is right or left footed is stored using a logical/Boolean field. The field is labelled as 'Right footed?' and the entry is either a TICK or left blank.