13

This question already has an answer here:

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

marked as duplicate by Paul White Jul 4 at 16:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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 May 15 '18 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. – Max Vernon May 15 '18 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 May 15 '18 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"! – Max Vernon May 15 '18 at 19:50
  • Hopefully, this would help some people figure out what we want when we close their question as "unclear". – Max Vernon May 15 '18 at 19:52
  • 1
    Ok, so we should definitely add some links to that close reason. – Aaron Bertrand May 15 '18 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 '18 at 15:50
  • 1
    @James - I'd recommend using ozh.github.io/ascii-tables - it's super easy. – Max Vernon May 16 '18 at 15:50
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 (as proposed by Max in his comment), I have come to the conclusion that adding an MCVE pages 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.

  • what do you mean by "take up a lot of space"? Do you mean the mcve itself? Or the proposed help page? – Max Vernon May 16 '18 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? – hot2use May 16 '18 at 17:11
  • Darn. I intentionally tried to keep it as short and concise as possible, knowing many people like to "tl;dr" – Max Vernon May 16 '18 at 17:17
  • The stackoverflow page on mcve has quite a bit more text, although it doesn't include an actual usable mini-mcve – Max Vernon May 16 '18 at 17:18
  • Just had a look. You are right. – hot2use May 16 '18 at 17:27
  • @MaxVernon There you go. Rephrased answer based on comments and SO MCVE page. – hot2use May 16 '18 at 17:34
0

I've created a question containing the mcve from above, here.

Please feel free to modify the MCVE as you see fit, but let's try and keep it simple.

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