Você está na página 1de 5

Databases

Introduction DEFINITION: A database is a collection of data or information which is held together in an organised or logical way. Computerised Databases There are many examples of computerised databases, some of which you will have used at home or school. In order to find the right web sites for you. Search engines need a vast computerised database which they search using your entered keywords Many schools now use electronic registers. These contain a database with records for every student in the school. The database records student's attendance both at school and in lessons. If you don't want to use the paper-based version, a telephone number can be found using an online database such as yell.co.uk. Type in the category you are looking for e.g. builder, type in the area e.g. Warwick and a search will be performed on all the records in the database before giving you a list of results which match your requirements a second or so later. Details of every person in the United Kingdom over the age of 18 are kept on local electoral registers. This database records your name, address, date of birth and national insurance number. The police use various databases to help them track criminals and solve crimes. They are able to look for trends or patterns in crimes and this helps them to establish whether a person could be responsible for a series of burglaries or assaults that have been taking place. They are able to co-operate with other police forces and share their information. A library stores details of all their books, in a database. When you want to know if a book is in stock, you can not only look it up, but you can also check when it is due to be returned. The database also records details of all the borrowers, what books they currently have borrowed and when they are due back. Computerised Vs paper-based databases

Tables Databases store data or information in tables, just like the one below: The table allows you to see all of the records stored in the database. Tables can store many records, from a few dozen for a small database up to millions for a large company database.

Records As you saw previously, each table can store a great deal of data. Each table contains a lot of records. DEFINITION: A record is all of the data or information about one person or one thing. In the table all of the information about each cartoon character is stored in a 'row' or 'record'. Fields Each table contains a lot of records. A record is made up of lots of individual pieces of information. Look at Wonder Woman's record: it stores her first name, last name, address, city and age. Each of these individual pieces of information in a record is called a 'field'. DEFINITION: a 'field' is one piece of data or information about a person or thing. Data Types When you are about to set up a database, you need to think about the 'data type' which you will use for each field.

Primary Key When you started school, you were given a 'student ID' or a 'candidate number' (primary key). This enables all of the girls called Charlotte Smith to be recognised. Therefore, it is important that every single record in a database has something to uniquely identify it and this is called the 'Primary Key' or sometimes the 'Key Field'.

Field Lengths Once you have chosen your datatypes, you need to think about the best 'field length' for each field. Most databases will have a default field length set up, in this case it is 50. This means that each text field is able to store up to 50 letters, numbers or symbols. In some situations, you may need to use all 50, but think about forenames. How long is the longest one you can think of? Probably around 12. What about surname? Even a double-barrel surname is unlikely to need more than 20 letters. The reason that you shouldn't just leave the field length as the default number is because every single character space allowed takes up one byte of storage space in the database, so a field size of 50 would need 50 bytes of storage. Validation As well as choosing the correct data types to try to reduce the number of errors made when entering data into the database, there is another method that can be used when setting up the table. This is called 'Validation'. It is very important to remember that Validation cannot stop the wrong data being entered, you can still enter 'Smiht' instead of 'Smith' or 'Brown' instead of 'Green' or '78' instead of '87'. What Validation can do, is to check that the data is sensible, reasonable and allowable. Verification It was mentioned that validation cannot make sure that data you enter is correct, it can only check that it is sensible, reasonable and allowable. However, it is important that the data in your database is as accurate as possible. Have you ever heard of the term 'Garbage in, garbage out' or 'GIGO'? This means that if you enter data that is full of mistakes (garbage in) then when you want to search for a record you will get data with mistakes presented to you (garbage out). This is where Verification can help to make sure that the data in your database contains as few mistakes as possible. Verification means to check the data that you have entered against the original source data. Think about when you choose a new password, you have to type it in twice. This lets the computer check if you have typed it exactly the same both times and not made a mistake. Flat-File Databases When you first set up your database, you can choose to make a 'flat-file' database or a 'relational' database. With a flat file database, all of your data is stored in one large table. Repeating data unnecessarily like this is called 'data duplication' Relational Database A flat file database isn't always the best choice as it causes a lot of data duplication. The answer to this is called a relational database.

In the database below, used at a vets, the data is split up into sensible groups i.e. customer data, pets data and appointments data. Then a separate table is made for each group. Once the tables have been set up, a relationship can be created to link them together - as shown by the lines linking the tables below. This is known as a 'relational database'. The main benefit of a relational database is that data doesn't have to be duplicated. When a customer books an appointment for their pet, a new record is created on the 'appointment's table' and the relevant Customer and Pet IDs are chosen. Reducing data duplication reduces the amount of data which needs to be stored, thus making the database smaller. It also reduces the risk of mistakes.

Database Queries Databases are extremely good at storing data or information. However, they are only any use if we can find specific information from them. Searching the database to find specific information is known as a query. If we wanted to search our Vet's database to find all of the dogs he looks after, we would set up a query and choose the criteria 'dog' as shown right: We would then 'run' the query and the database would search for all of the records which matched the criteria 'dog'. Queries can also be used to search for more than one thing. Query Operators
Logical Operators Common Operators

Reports Once you have run a query, the results are displayed in a table. Whilst this shows all of the data, it isn't very nicely presented. Also, if you had hundreds of results then it might be hard to look at all of the data and pick out specific things. There is a much nicer way of presenting the same data, this is called a report: This report looks much more professional than a table of data. Note that 'pet name' has been sorted into alphabetical order or ascending order. Databases will let you sort any field in ascending or descending order.

Summary A database is a collection of data or information which is held together in an organised or logical way. Many databases are computerised. Databases store data or information in tables Each table consists of a number of records Each record is made up of a number of fields Every record has an unique identifier called the primary key Validation tries to make sure entered data is sensible, reasonable and allowable Verification means checking the data more than once e.g. typing a new password twice to make sure mo typing mistakes have been made. A flat file database only consists of one table A relational database consists of a number of tables each with a relationship with at least one other table A table in a relational database is linked to other tables by making use of their primary keys. A query is used to extract data from a database Comparison Operators and Logical Operators are used to set up a query Reports present the results of a query in a neat, well laid out format.

Você também pode gostar