A bookshop is experimenting with SQL queries with the aim of assisting customer queries in a more efficient manner.”
Publisher Table: tblPub
PubID | Name | Location | Founded |
1 | Dolphin House Publishing | New York | 2013 |
2 | SmithGilles | New York | 1989 |
3 | MacNeillie Publishers | London | 1843 |
4 | Robert & Hamilton | New York | 1924 |
5 | Dubois Leroy | Paris | 1826 |
Books Table: tblBooks
BookID | Title | Genre | Author | PubID |
100 | Clues in the Dark | Mystery | Birt Taylor | 1 |
101 | Fires of the Moon | Fantasy | Erika Robins | 5 |
102 | Lives of Legends | Biography | Daniel Raulter | 4 |
103 | Famous Figures | Biography | Alice Clang | 4 |
104 | Kingdom of Fortune | Fantasy | Emily Bowson | 4 |
105 | The Unsolved Mystery | Mystery | Edward Laff | 2 |
106 | Explore the Cosmos | Academic | Dr Roger Puckey | 2 |
107 | Dragons of the South | Fantasy | Michelle Garrickson | 3 |
108 | Remarkable Journeys | Biography | James Singer | 5 |
109 | The Classified Story | Biography | Andrea Tangle | 2 |
a.
Write an SQL query that sorts the book genres in ascending order. All fields are to be included.
(2 marks)
b.
Write an SQL query to retrieve the book titles in the ‘Academic’ or ‘Biography’ genres.
The query must include the book title and genre.
(3 marks)
c.
Write an SQL query that joins the two tables based on the relationship between the primary key and the foreign key.
Records must list the publisher’s name and the book title.
(4 marks)