There are many problems puting logic in the database. Many would advice against it. It is much more difficult to manage a system where logic is spread out through many layers. Think carefully before going this path.