Sorting Records in Databases
Database packages are extremely useful and good at storing, searching and sorting data, for example names and addresses, customer details, pupil test scores.
Even when databases files are large, containing millions of records, they are good at sorting through information very quickly. Sorting through database can either be:
- Simple or;
- Complex
- Each RECORD contains ALL the information about one particular person or object. Separate piece of information in the RECORD are held in:
- FIELDS. A FIELD contains one individual piece of information found on a single record. FIELDS are often given field names to describe the information they contain.
What you have to do! - Simple Sorting
How to do Simple & Complex Sorting!
Click to Go Larger Screen
|
- Using the FOOTBALL TEAM KITS database file, and; .
- Watch Video 2 .
- Use the information from the movie to answer the following questions in Exercise 2 of the General Section of your PROGRESS Grids
- Sort the database by stock number in ascending order.
- Write down the stock number of the teams who are first and last on the list.
- Sort the categories in in descending order. Write down the number of the last kit listed.
- Which kits have the greatest and least number in stock? Write down the stock number.
Mark off Exercise 2 in your Progress Grids
Simple sorts generally involve sorting on one field, price for example or pupils test scores, or stock level.
Often though its is useful to sort on two or more fields, especially when some of the fields contain duplicate data. For example, many people have share surnames or are sold at the same price, so how there is a problem of how to distinguish between people or different products.
What you have to do! - Complex Sorting
- Download the Paintings.fp7 Database and place in your Database folder.
- Watch the second half of Video 3 above to see how to complete Complex Sorts.
- Open the database file PAINTINGS and answer the following questions in Exercise 3 in the General section of your PROGRESS Grids.
- Sort by type and then seller code. Write down the 11th and 37th catalogue number listed.
- Sort by seller code and then by painting type. Notice the difference in this sort to the previous sort, although the same fields are used.
- Sort by seller code followed by painting title. The title should be sorted in descending order. Write down the catalogue number of the 9th record listed.
- Sort by reserve cost and then by painter surname. Finally the painter forename should be sorted so that all paintings by a particular artist are displayed together. Write down the catalogue number of the 5th and 25th paintings listed.
- Sort by catalogue number followed by the reserve price. Write down the 10th catalogue number listed.
- Sort by catalogue number followed by seller code. Write down the 10th catalogue number listed.
- Write down what you notice about the results of questions 5 and 6. Write down the reasons why these sorts behave in the way that they do.
Mark off Exercise 3 in your Progress Grids
What you should be able to do now!
-
Understand the difference between Ascending and Descending sorts.
-
Complete Simple Sorts using one field.
-
Complete Complex Sorts using multiple or more than one field.