sql - Stored procedure for adding a movie -


i'm creating stored procedure adding movie (i'm working on application stores , lists movies information), , before getting started input on how create it.

i have following tables:

  1. "movie" (movieid, name, year, length, summary)
  2. "genre", list of genres (genreid, genre)
  3. "moviegenre", list of movies , genre/s. (moviegenreid, genreid, movieid)
  4. "movierole", stores name of actors/directors etc (movieroleid, name)
  5. "movieroletype", stores different kinds of roles movie, actor (movieroletypeid, movieroletype)
  6. "cast", list of movies cast's (castid, movieroletypeid, movieid, movieroleid)

when adding movie must provide information movie, @ least 1 movie role (eg. actor) , genre. should create several sp:s , execute them 1 sp, or how should do?

note: i'm not asking write whole sp me, asking guideline.

thanks in advance!

i create several separate stored procedures , use transaction make sure inserts committed together.

you going need separate sps add additional cast members, genres, etc. doesn't make lot of sense me have 1 large sp , of support code goes calling sp add new movie + role + genre , have separate sps (and support code) duplicate adding of roles , genres. using transaction wrap of separate sps single action making appear single sp giving flexibility use individual sps well.

you're going need support code call each of individual sps anyway. code validate parameters, handle errors, set sp's values, etc. you'll need functions addrole, addgenre, etc. in application. i'd rather have 1 function in code called addmovie started transaction , called each of these individual functions. break job small, testable pieces , build larger functions (addmovie) calling smaller pieces know work. more complicated build addmovie function called different sp lot of same things pieces have do.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -