13

StackOverflow has a great page in their help section on how to create a minimal, complete, and verifiable, example (MCVE).

I think it would be very helpful if we had a similar document showing how to create a simple MCVE for SQL related questions.

Something like this:


How to create a Minimal, Complete, and Verifiable Example for database-related questions

Database-related questions asking for practical advice will get the most helpful answers if they provide a framework others can use to reproduce that problem.

With that in mind, when asking a question please create a framework that is:

  • Minimal – Use as little code as possible that still produces the same problem
  • Complete – Provide all parts needed to reproduce the problem
  • Verifiable – Test the code you're about to provide to make sure it reproduces the problem

Minimal

Reducing the code to the bare minimum necessary to convey the problem makes the question easier to ask, and inherently easier to answer. Win-win. If you have a question about a query that has 400 columns, and all 400 columns are not required for the answer, only show the two or three columns that are pertinent to the question.

Complete

Include all the tables, queries, indexes, constraints, and other parts as necessary to ensure the person answering your question has all the information at the outset. When including these pieces, provide the SQL scripts so others don't have to recreate them. Do not provide screenshots of tables or results.

Verifiable

Include test output, in text formatted as a table, to show both what you're currently getting as well as what your desired output should be. Search for "ascii table generator" on your favorite search engine - there are several that are extremely easy to use.

An example question, including an MCVE framework

I want to get the total count of the number of ducks in each pond.

The ponds table:

CREATE TABLE ponds
(
      PondName varchar(30)
      , DuckName varchar(30)
);

Some sample data:

INSERT INTO ponds (PondName, DuckName)
VALUES ('Golden', 'Daffy')
     , ('Walden', 'Daisy');

My query so far:

SELECT COUNT(DuckName)
FROM ponds;

The output I'm getting:

╔═══════╗
║ Value ║
╠═══════╣
║     2 ║
╚═══════╝

The output I'd like to get:

╔════════╦═══════╗
║  Pond  ║ Count ║
╠════════╬═══════╣
║ Golden ║     1 ║
║ Walden ║     1 ║
╚════════╩═══════╝

Yes, the above sample question would be considered "too localized" for our site; this is just a quick example

8
  • 1
    Well, if we point them at the StackOverflow one and they still don't read it, why would they read one at a different domain name? I mean, I tried to get a living document going when the blog was hot. Didn't really catch on. dba.blogoverflow.com/2012/06/help-us-help-you
    – Aaron Bertrand Staff
    May 15, 2018 at 19:09
  • I thought it was great! I've looked for that recently and was unable to find it. I'm going to add it into the list of canonical questions/answers, to make it easily available.
    – Hannah Vernon Mod
    May 15, 2018 at 19:12
  • Also, to be clear, I'm not trying to sh*t on your idea. I've just lost hope that people will proactively read anything like that.
    – Aaron Bertrand Staff
    May 15, 2018 at 19:47
  • 1
    The people who do read that of their own accord never actually need to. The people who need it, will never be able to find it. That's why I'm always pointing people to the Stack Overflow version. And I never thought you were trying to "sh*t on my idea"!
    – Hannah Vernon Mod
    May 15, 2018 at 19:50
  • Hopefully, this would help some people figure out what we want when we close their question as "unclear".
    – Hannah Vernon Mod
    May 15, 2018 at 19:52
  • 1
    Ok, so we should definitely add some links to that close reason.
    – Aaron Bertrand Staff
    May 15, 2018 at 20:00
  • It would be nice if it were easier to paste query results into SE. Right now, it's kind of a pain to format.
    – James
    May 16, 2018 at 15:50
  • 1
    @James - I'd recommend using ozh.github.io/ascii-tables - it's super easy.
    – Hannah Vernon Mod
    May 16, 2018 at 15:50

1 Answer 1

1

Introducing an MCVE Chapter to our Help Centre would be a good idea. However, looking at your example it seems to take up a lot of space.

After reading through the help page on stackoverflow, I have come to the conclusion that adding an MCVE page is do-able and would be a valuable resource.

It would help the community being able to comment questions with a link to the MCVE Help Page when questions lack substance and for newcomers who actually take the time to read through the Help Centre.

6
  • what do you mean by "take up a lot of space"? Do you mean the mcve itself? Or the proposed help page?
    – Hannah Vernon Mod
    May 16, 2018 at 15:43
  • The proposed information / help page as you laid out in your question. Or would you limit the description / information in the help centre?
    – John K. N.
    May 16, 2018 at 17:11
  • Darn. I intentionally tried to keep it as short and concise as possible, knowing many people like to "tl;dr"
    – Hannah Vernon Mod
    May 16, 2018 at 17:17
  • The stackoverflow page on mcve has quite a bit more text, although it doesn't include an actual usable mini-mcve
    – Hannah Vernon Mod
    May 16, 2018 at 17:18
  • Just had a look. You are right.
    – John K. N.
    May 16, 2018 at 17:27
  • @HannahVernon There you go. Rephrased answer based on comments and SO MCVE page.
    – John K. N.
    May 16, 2018 at 17:34

Not the answer you're looking for? Browse other questions tagged .