* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Fields and Properties
Data center wikipedia , lookup
Expense and cost recovery system (ECRS) wikipedia , lookup
Data analysis wikipedia , lookup
Concurrency control wikipedia , lookup
Versant Object Database wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
3D optical data storage wikipedia , lookup
Information privacy law wikipedia , lookup
Business intelligence wikipedia , lookup
Open data in the United Kingdom wikipedia , lookup
Data vault modeling wikipedia , lookup
Relational model wikipedia , lookup
A DATABASE AND ITS COMPONENTS A database is an organized collection of data. It is kept to enable the user to access information quickly and efficiently in the future. In order for this to be possible the database needs to be carefully designed and data input must be careful and accurate. The smaller we make the items of data that we store the more powerful the database can be. A Database is composed of files - or in a relational database these are called 'tables'. A table represents an object or 'entity' about which we want to store data. Step 1 is to decide on the entities in our database. Each table contains whatever 'fields' we put into it. A field holds a single item of information about an object or entity. For example for the entity STUDENT we would want to record the STUDENT_ID so we would create a field with this name and into it would put the Student_ID for each student. These pieces of data are called 'attributes' and they are stored in the fields. We name the fields so that it is easy to understand what they contain! A record is the complete set of data on a particular entity - for example all the items of data we store on one student such as ID, Name, Address, Tel No, Age, Height etc. A Relational Database (Access) is made up of a number of Tables which represent the objects or entities. Relationships are defined by the user between entity tables in the database enabling many useful searches to be made for data in the database. SETTING UP DATABASE TABLES 1. Identify the 'entities' that we need in the database 2. We set up a table for each entity 3. We decide on the 'fields' that need to go in each entity table 4. For each field we must decide what type of data it will hold and any special properties that the data must have DATA TYPES The types of data that can be stored in a field must be defined and can belong to one of the following categories Data Type Description Text A character string with a maximum length of 255 characters Memo A character string with a maximum length of 64,000 characters. Usually used for descriptions of items. Cannot be used as a Primary Key Una Dooney Page 1 Database Field Properties Data Type Description Number Various types of numbers. Double (15 places, 8 bytes) Single (7 places, 4 bytes) Long Integer (-2.1 billion to +2.1 billion, 4 bytes, no decimals) Integer I-32 to +32 thousand, 2 bytes, no decimals) and Byte (values 0 to 255, 1 byte, no decimals) AutoNumber The database will automatically generate numbers for this field. Usually unique identifier for primary key purposes Yes/No Used to store logical results from True/False results. Be careful as –1 stands for Yes and 0 stands for No Date/Time Used to store dates and times. Format can be changed Currency Used for storing numbers (not necessarily in money format). Can hold 15 places to the left of the decimal point and 4 places to the right. Takes up to 4 bytes OLE Object Used for linking other files to the database such as spreadsheet Hyperlink Used for storing web addresses FIELD PROPERTIES Field properties are set to control how the data in a field can be entered and displayed and in some cases to limit the type of data that can be entered. When setting up a table you need to go through the list below for all fields Field Name Each field name must be unique A field name can have a maximum of 64 characters A field name can be any combination of letters or characters or spaces or special characters EXCEPT Exclamation mark ! Accent grave ` Full stop . Brackets () or {} or [] Do NOT begin a field name with a space Although it is allowed to include spaces in field names it is much BETTER not to. Use CustomerName of for clarity use the underscore symbol is often used to separate words ie Customer_Name Data Type Select the data type from the list given previously Field Size Allows you to limit the number of characters that can be entered Primary Key Uniquely identifies a record in a table. A table must have a Primary key defined before it is saved. Ensures that no two records in the same table can contain the same data in the key field. (Atomic data value) Una Dooney Page 2 Database Field Properties Input Masks Input masks are used to format data and provide some control over what values can be entered in a field. Input masks can be used in tables, and in combo boxes and text boxes in forms. Mostly they are used with Text and Date/Time field types Examples are if we want all the names in our database to have initial capitals but the rest of the names in lowercase. Use of Input Masks – To ensure the lettering in the database is consistent. It does not matter how we type in the data it will be displayed the same in all records >?<??????????? Result >????????????? Result To display an initial capital letter and the rest small letters Dublin Aberdeen To ensure that all the letters appear in capitals DUBLIN ABERDEEN The ? represents any letter from A-Z (entry optional) The L represents any letter from A-Z (entry required) With ? if a name is shorter than the number of characters specified for the field the data is accepted. If the L is used then for each L in the input mask there must be a letter in the field entry (Not a great idea for people’s names since they are all different lengths A couple of other useful characters to know are: 0 9 # + [a digit 0-9, entry required, + and – signs not allowed] [a digit or space, entry not required, + and – signs not allowed] [a digit or space, entry not required, blanks positions converted to spaces and – allowed] Input masks can be used for formatting but also to ensure that the data entered follows a particular pattern so can help with Data Integrity. Input masks are used for telephone numbers, Postcodes, Social security numbers etc. Input masks do not work with all data types. An input mask for a phone number can limit the number of digits that are entered and ensure that only numbers and not letters are entered. A full list of input mask characters is given in Access/Help Validation Rules Validation rules are to help to prevent input errors by limiting the data that fields accept. For example if a company had commenced business in 1999 then a validation rule could prevent them having hired any employees before 1999. This would force the entries to be after the date specified Una Dooney Page 3 Database Field Properties The mathematical operators are: < > <= >= <> less than greater than less than or equal to greater than or equal to not equal to <#1/1/99# >#1/1/99# Examples of what is typed in the Field Properties Rule >=#1/1/99# and <= #14/2/04# =”UK” Or=”USA” Or=”IRL” <=Date() <>#25/12/04# >=100 =”Male” or “Female” What it means date must be between 1/1/99 and 14/2/04 only the data shown will be accepted Today at the latest Not Christmas Day Must be greater than or equal to 100 Must enter the words Male or Female Validation Text This is a message typed by the Database designer in the appropriate place in the field formatting section, to tell the person entering data that they have made an error and the type of entry that is allowed Required Property (Yes/No) A field can be set that it cannot contain a Null value (cannot be empty). The key field or primary key needs to be set for required - Yes Una Dooney Page 4 Database Field Properties Default Value You can set the default value or text for a field to save time inputting data later. Obviously you can overwrite the default value if it is not what is required in a particular record OTHER DATABASE DEFINITIONS Referential Integrity Prevents users from entering inconsistent data in the database. These rules are applied when you are creating relationships between two tables. It ensures that the relationships in the database are enforced. The term Data Integrity means that the data in the database is correct, consistent and up-to-date at all times. For example if we have a Properties table and an Owners table, we cannot list an Owner in the Properties table if he/she does not exist in the Owners table. Normalisation This makes the tables as efficient and compact as possible to eliminate error and confusion. There are a number of normalization rules eg (i) Avoid repeated information – for example if you are recording customer orders it would be very wasteful of time and space to record their name and address etc each time they placed an order. It is better to assign each customer an ID and put that information into a separate table and then just refer to their ID in the Orders table Foreign Key A non-primary key field which is linked to the primary key of another table OTHER DATABASE OBJECTS Tables are only one of the objects we find in an Access database. Some of the others are briefly described here. Forms A Form is a data entry tool. Example might be an Order form. When entering data using a form you see only one record at a time. When you are entering data in a table you can see a number of records at once. Tables can be easily converted into Forms using Autoform or by designing your own. A database can be updated through a form or a table. Queries Are a way of sifting or filtering out information you do not want to see and also selecting information/data that you do want to see ie ‘When did we employ Rose Townsend?”. The results of a query can be saved or discarded. Queries can be used as a basis for a report. Reports Used to present data and information. There are a number of layout options. They can use tables or queries as their source. Data can be organized so that it is easier to understand. Una Dooney Page 5 Database Field Properties