See Database Security Overview for Application Developers chapter of Application Developer's Guide for more information. You would enjoy an example in Creating Secure Application Roles section.