Download - Databases
![Page 1: Databases](https://reader036.vdocument.in/reader036/viewer/2022082712/56813ce4550346895da6892d/html5/thumbnails/1.jpg)
Databases
Searching and Sorting
![Page 2: Databases](https://reader036.vdocument.in/reader036/viewer/2022082712/56813ce4550346895da6892d/html5/thumbnails/2.jpg)
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
![Page 3: Databases](https://reader036.vdocument.in/reader036/viewer/2022082712/56813ce4550346895da6892d/html5/thumbnails/3.jpg)
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
![Page 4: Databases](https://reader036.vdocument.in/reader036/viewer/2022082712/56813ce4550346895da6892d/html5/thumbnails/4.jpg)
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
![Page 5: Databases](https://reader036.vdocument.in/reader036/viewer/2022082712/56813ce4550346895da6892d/html5/thumbnails/5.jpg)
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
![Page 6: Databases](https://reader036.vdocument.in/reader036/viewer/2022082712/56813ce4550346895da6892d/html5/thumbnails/6.jpg)
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
![Page 7: Databases](https://reader036.vdocument.in/reader036/viewer/2022082712/56813ce4550346895da6892d/html5/thumbnails/7.jpg)
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
![Page 8: Databases](https://reader036.vdocument.in/reader036/viewer/2022082712/56813ce4550346895da6892d/html5/thumbnails/8.jpg)
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
![Page 9: Databases](https://reader036.vdocument.in/reader036/viewer/2022082712/56813ce4550346895da6892d/html5/thumbnails/9.jpg)
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