Which local events can you go to for €5 or less, and where are they on?
You've a fiver to spend on a local event. You want to see what you can afford and where each event is on. If an organiser drops a ticket price, how can you tell whether the next search uses the new price?
Before you design anything, write down what the visitor needs: choose a budget, see the cheapest matches first, and see each title beside its venue. You already know that a row holds one record. An event row can store a venue ID that points to a row in the venue table.
In your project folder, run sqlite three events dot db. Use SQLite version three point three seven or later. Enable foreign key checks for this connection. Create venues with integer IDs and text names, then events with integer IDs, text titles and fees in whole cents. Each event references a venue.
Suppose you're about to add a film night with venue ID two. Foreign key checks are on. Which record must already exist before that insert can succeed? Pick one answer.
Add the venues first. Town Hall Theatre gets ID one and Triskel Arts Centre gets ID two. Then add Film Night at five euro, Choir Live at three and Art Workshop at seven. Put names and titles in quotes. Write IDs and fees in cents as integers without quotes.
Select the event title and venue name. Start from event, called e, then join it to venue, called v. Match their venue IDs. Keep fees of five hundred cents or less. Sort by fee, cheapest first, then by event ID to break ties. Save the SQL as search dot sql beside the database.
You change the filter from five hundred cents or less to four hundred cents or less. Leave the join and the ordering alone. Think about the fees you inserted, then pick the title and venue the query will return.
Install Streamlit with pip install streamlit. Save this as app dot py beside events dot db. The app opens the database, takes a budget in cents, passes it to the query’s question mark and displays the returned rows. From that folder, launch it with streamlit run app dot py.
In the SQLite shell, run search dot sql with the dot read command. Choir Live at Town Hall Theatre comes before Film Night at Triskel Arts Centre. Update event three to two hundred cents. Run the same file again. Art Workshop at Town Hall Theatre now comes first.
For a Leaving Cert style task, describe how your system meets the visitor’s budget requirement. A hand-typed table stays the same when you update a fee in the database. Reload your search page at five hundred cents. Art Workshop should now appear first without you editing the page.