Adding stored procedures for the database

Stored procedures code. For impelmenting, just run the queries one by
one.