Note that there are some explanatory texts on larger screens.

plurals
  1. POWorth the headache to organize SQL files by application subject?
    text
    copied!<p>At my company, we save each database object (stored proc, view, etc) as an individual SQL file, and place them under source control that way. </p> <p>Up until now, we've had a very flat storage model in our versioned file structure:</p> <ul> <li><code>DatabaseProject</code> <ul> <li><code>Functions</code> <ul> <li>(all functions here; no further nesting)</li> </ul></li> <li><code>StoredProcedures</code> <ul> <li>(all stored procs in here; no further nesting)</li> </ul></li> <li><code>Views</code> <ul> <li>(ditto)</li> </ul></li> </ul></li> </ul> <p>For a big new project, another idea has occurred to me: why not store these files by subject instead of in these prefab flat lists? </p> <p>For example:</p> <ul> <li><code>DatabaseProject</code> <ul> <li><code>Reports</code> <ul> <li>(individual stored procs, views, etc.)</li> <li><code>SpecificReport</code> <ul> <li>(more objects here, further nesting as necessary)</li> </ul></li> </ul></li> <li><code>SpecificApplication</code> <ul> <li>(all types of DB objects, with arbitrarily deep nesting)</li> </ul></li> <li>et cetera....</li> </ul></li> </ul> <p>The obvious flaw is that this folder structure doesn't impose any kind of namespace hierarchy on the database objects; it's for organization only. Thus, it would be <strong>very easy to introduce objects with duplicate names</strong>. You'd need some kind of build tool to survey the database project and die on naming conflicts. </p> <p>What I'd like to know is: has anyone tried this method of organizing SQL files by application subject in their versioned file structure? Was it worth it? Did you create a build tool that would police the project as I have described?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload