Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7598527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:25:42+00:00 2026-05-30T22:25:42+00:00

I am writing a large number of SQL scripts to be shared by a

  • 0

I am writing a large number of SQL scripts to be shared by a number of people, who will generally work with the scripts by editing them slightly for their specific purpose, then using the modified script to generate a dataset for further analysis.

I’ve struggled with the best way to build and organize such a library. I want more structure than just a folder with a long list of files like “signups_and_spend_by_week.sql.” I see basically two, inter-related issues:

  • Parameterization. Things like dates and sample sizes are relatively easy to pull out and make into variables, but what about parameters that alter the nature of the query—say changing a left join to an inner join? Is it wise to just (a) comment these kinds of possibilites, (b) create two versions (hence creating serious DRY problems), or maybe (c) wrap queries with a higher-lever programming language that can more easily represent these kinds of possibilites, e.g.,

       q = "SELECT * FROM plants" 
       if want_all: 
           q = _q + "LEFT JOIN fruits ON fruits.plant_id = plants.id"
       else: 
           q = _q + "INNER JOIN fruit ON fruits.plant_id = plants.id"       
    
      run_query(q)  
    
  • DRY. I find that the same patterns continually appear, with similar or identical views being created as intermediate steps for more complex queries. My thinking is to split these re-usable bits out and call them as needed. However, my concern is that this then creates dependencies all over the library, and that seemingly innocuous changes to a “base” query might might inadvertently break someone else’s query. Other than just discipline and good documentation/rules, is their some compromise possible, e.g., automated testing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:25:43+00:00Added an answer on May 30, 2026 at 10:25 pm

    This looks like a problem that should not be treated in a purely technical way.

    Basically you will offer a base of SQL’s that other people can refine.
    Some of your base SQL’s will have bugs, run slow in certain circumstances, solve problems that don’t exist, are spot on, … and they will be improved, altered, neglected, praised, …

    It is hard to foresee what will work best for you and your co-workers. At least I don’t have an idea.

    I would suggest that you first start very basic, very simple: with a directory with SQL scripts, giving the files meaningful names.
    – Allow people to look at them, use them, change them, derive from them, comment on them, give points for their usefulness, ….
    – Have frequent meetings with all involved.
    – Try to find out what works well, what your group needs, what things don’t work at all, ….
    – Only when you, as a group, start to see clearly what tools you need to support what you’re doing, start thinking and designing a system to supports your needs. Only then store your scripts in a database, if that still makes sense.

    Don’t start designing now, you will probably throw 80% away, and the 20% you keep will be to spare the feelings of the one who has spent so much time up front trying to come up with something useful for the group.

    For me this is really a situation where a SCRUM approach works best: a situation that no one has a clear view of on how it should be best build. Communication, short sprints that try to address problems, interactivity, change the things that didn’t work out as planned, … those seem to me the key words and phrases for this project.

    Let it grow, don’t assume you can grok now how it will be.

    (I wrote this out of the assumption that it is as clear to you as it is to me how your project will evolve. If you have a clear view of what it will look like and have done this before, my comments will be way off.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a game where a large number of objects will have area effects
I'm writing a program which will need to do a very large number of
I am writing Windows application (with Borland C++ Builder), which stores large number of
I am writing a fairly large C++ shared-object library, and have run into a
I'm writing a program which creates a large number of large arrays to store
I am writing an application that reads in a large number of basic user
I'm writing an application which creates a potentially large number of forms to display
Is there a better way for writing a condition with a large number of
I'm writing a program in .net where the user may provide a large number
I'm writing a C++ program that has a large number of classes. In my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.