90 likes | 245 Vues
Databases. Searching and Sorting. SIMPLE search. A SIMPLE search is when you use only ONE field to search the database. e.g. Searching a football database to find all teams that play in Spain So you would use COUNTRY = “Spain” (only ONE field is used). COMPLEX search.
E N D
Databases Searching and Sorting
SIMPLE search A SIMPLE search is when you use only ONE field to search the database. e.g. Searching a football database to find all teams that play in Spain So you would use COUNTRY = “Spain” (only ONE field is used)
COMPLEX search A complex search uses TWO OR MORE fields to find information So searching the same database would be as follows COUNTRY = “Spain” AND Colours = “White”
Examples of Simple searches • Eye Colour = “Blue” • Country = “Italy” • Language = “Spanish” • Stays in = “Lochwinnoch” Anything that uses just ONE field in a database is a SIMPLE search
More SIMPLE searches If you have a numeric field then it is possible to search that in a slightly different way. Look at the extract from countries database Since it is a numeric field we can treat the contents as a number therefore Population > 100 gives 2 countries Japan and Brazil
More COMPLEX searches • Eye colour = “Blue” AND Hair Colour = “Brown” • Town = “Johnstone” AND Primary = “Thorn” • Currency = “Euro” AND Population > 20 million • Cost < £1 AND Type = “drink” • Height > 2m AND Right handed = “Yes” • Resort = “Corfu” AND Cost < £400
SORTING a database • Sorting a database involves using ONE or MORE fields and putting them in order. You can either sort • ALPHABETICALLY (a-z or z-a) • NUMERICAL (ascending or descending) YOU HAVE TO TELL THE DATABASE WHAT FIELD YOU ARE SORTING THOUGH
More SORTING Sorted using height field ascending
SUMMARY Do you know the difference between SIMPLE SEARCH And COMPLEX SEARCH Make sure you tell the database which FIELD or FIELDS you intend to search. Do you know the difference between Sort ascending or descending Numerical Sort and Alphabetical Sort