Configurable database schema

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Configurable database schema

    Is there a reasonable way to set up an application such that the database
    (specifically Oracle) schema owner used by all of the queries is configurable?
    For example, in SQL*Plus I can log in as the REPORTER user, execute "ALTER
    SESSION SET CURRENT_SCHEMA = APPOWNER_DEV", then all queries that I run from
    that point will use the database object naming resolution as if I were the
    APPOWNER_DEV user (meaning I can omit schema names entirely) but use the
    permissions of the REPORTER user. Later when I need to run the script in the
    production environment I set current schema to APPOWNER_PROD and no other SQL
    statements need to be changed.

    I was hoping there was some way to set up the DSN such that the "current
    schema" was set as desired each time a new database session was opened.

    Other options that are being considered:
    1. Hardcode the schema name and do a project-wide search-and-replace with the
    schema names if the target environment uses a different schema.
    2. Log in directly to the database as the application owner.
    3. Create scripts to create/recreate synonyms (private or public) to address
    the "hiding" of the schema information.
    4. Set up all SQL scripts such that the schema name is a variable.

    All of these options have some downside. Of course I'm open to other options.
    The goal is to make the move between environments require the fewest changes
    possible.

    Thanks,
    Brian Gastineau

    Brian G. Guest

  2. Similar Questions and Discussions

    1. how to prep database schema
      Hi I ve a huge database created in MySQL by someone else. now i want to view all the tables and their relationships so tht i can design the...
    2. Loading Database Schema
      Hi, Each time I save a file, or open a file, or even thinking about modyfying a file, a stupid stupid stupid stupid message box pops up with...
    3. Looking for sample code and database schema
      I've been handed a project to design and implement a survey system for our intranet. I'm looking for sample code snippets (ASP Classic) or in...
    4. Newline after <?..?> block behaviour configurable?
      Hi. I find it increasingly annoying that newlines after blocks of PHP code are automatically stripped. I know that this is documented, and may...
    5. Change the database schema without changing the application?
      Hi, I'm writing a C++ application that needs to retrieve a whole row of data from a table, which has 148 columns, to be displayed on the GUI. So I...
  3. #2

    Default Re: Configurable database schema

    On re-read, option 4 should have been:

    4. Set up all CF templates such that the schema name is a variable in the SQL statement.
    Brian G. Guest

  4. #3

    Default Re: Configurable database schema

    We took a different approach, for security and modularity reasons, that may be
    an alternative for you to consider. We put all of our SQL into PL/SQL stored
    procedures within packages, rather than writing the queries directly within
    ColdFusion. We use CFSTOREDPROC instead of CFQUERY tags, and can reuse code
    very easily. The beauty of this was that we created the packages in the main
    schema, and created public synonyms for them. Then, for the other users/schema
    names, we only granted the EXECUTE privilege on the package or packages to
    those user names that needed by that user. So, in the CFSTOREDPROC tag, the DSN
    would be the same for all procedure calls, but you could use a "dynamic" user
    ID and password, and that schema would be able to execute the procedure called
    because it has been granted the execute privilege, without having to grant any
    other object privileges on the "main" schema. (Just make sure that your package
    has the appropriate full privileges on your main schema.)

    This is a good way to restrict access to your database to only those functions
    and procedures that you wish to grant access to, by means of making them
    available in the package. By not allowing any other SQL from ColdFusion, you
    can also divide up your development into presentation and application sections,
    so that your database experts can concentrate their efforts there, and your
    ColdFusion specialists can focus on the interface, etc. Develop an API and
    specs, so that GUI and database developers stay on the same page. It may seem
    to be a lot of overhead and overkill for some apps, but it works great if you
    got lots of developers, especially if you want to keep your GUI coders out of
    the database (DBAs really like this).

    Phil

    paross1 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139