Project Assignment 15
Transactions and Stored Procedures
Your boss is out of town this week, thankfully! "Awesome, I can actually get some work done instead of being constantly interrupted by his lame dirty jokes," you think.
You decide to refactor some of the database operations available to the other developers. First, you decide to create a transaction 'template' for the developers to use. Second, you decide to implement a stored procedure, since you heard the developers complaining about what a pain it's been creating their own SQL strings by hand.
Create a transaction and a stored procedure
This assignment shouldn't take too long. Create one transaction and one stored procedure:
- Create a transaction that inserts a new artist, a new album, and all the songs for that album. Remember, this is meant to just be a 'template', so you can be explicit with the data you insert.
- Create a stored procedure that accepts a song id, and returns the song's title.
- BONUS: if your artists table has a counter for albums, create either a stored proc or transaction that inserts a new album into the database, and increases the album counter for the artist. Feel free to add the num_albums field to your artists table if you want to give this one a shot.
Hints
Use the MySQL documentation for help with the syntax.
Specific Tasks
Include the transaction and stored procedure in your documentation.
To be completed by Monday, April 21