databases
DESCRIPTION
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. - PowerPoint PPT PresentationTRANSCRIPT
Databases
Searching and Sorting
SIMPLE searchA 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)
Team Country Stadium Colours Star Player
Liverpool England Anfield Red Gerrard
Real Madrid Spain Bernabau White Van Nistelrooy
AC Milan Italy San Siro Red/ Black Kaka
Barcelona Spain Nou Camp Red/ Blue Ronaldinho
Bayern Muncih Germany Allianz Red Riberry
COMPLEX searchA complex search uses TWO OR MORE fields to find information
So searching the same database would be as follows
COUNTRY = “Spain” AND Colours = “White”
Team Country Stadium Colours Star Player
Liverpool England Anfield Red Gerrard
Real Madrid Spain Bernabau White Van Nistelrooy
AC Milan Italy San Siro Red/ Black Kaka
Barcelona Spain Nou Camp Red/ Blue Ronaldinho
Bayern Muncih Germany Allianz Red Riberry
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 searchesIf you have a numeric field then it is possible to search that in a slightly different way.
Look at the extract from countries database
Country Capital City Currency Population (millions)
Language
Egypt Cairo pound 80.3 Arabic
Israel Jerusalem Shekel 6.4 Hebrew
Latvia Riga Lats 2.3 Latvian
Japan Tokyo Yen 127.3 Japanese
Brazil Brasilia Real 190 Portuguese
Portugal Lisbon Euro 10.6 Portuguese
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 SORTINGName Height
(m)
Eye Colour
Right Handed
Jane 1.6 Blue No
Bill 1.7 Hazel Yes
Bob 2.4 Hazel No
Alice 1.8 Green Yes
Name Height
(m)
Eye Colour
Right Handed
Jane 1.6 Blue No
Bill 1.7 Hazel Yes
Bob 2.4 Hazel No
Alice 1.8 Green Yes
Sorted using height field ascending
SUMMARYDo 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