1 /*	$Id: test.sql,v 1.9 2016/07/14 09:10:27 kristaps Exp $ */
    2 /*
    3  * Copyright (c) 2016 Kristaps Dzonsons <kristaps@kcons.eu>
    4  *
    5  * Permission to use, copy, modify, and distribute this software for any
    6  * purpose with or without fee is hereby granted, provided that the above
    7  * copyright notice and this permission notice appear in all copies.
    8  *
    9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   16  */
   17 
   18 PRAGMA journal_mode=WAL;
   19 
   20 -- sqliteconvert is a set of tools to extract documentation from
   21 -- [SQLite](https://www.sqlite.org)
   22 -- database schemas. 
   23 --
   24 -- Documentation, in this regard, consists of the schema itself and
   25 -- comments prior to each table and comment.
   26 -- What you're reading right now is part of the comment above the table
   27 -- called ``INTRODUCTION''.
   28 -- The result of this extraction is this HTML5 page.
   29 -- It consists of an image showing the schema, the documentation, and an
   30 -- image map linking the two.
   31 -- All of these are contained on this page: clickable image-map on the
   32 -- left, target documentation on the right.
   33 -- Click and find out!
   34 CREATE TABLE "INTRODUCTION" (
   35 	-- The tools generating this page are
   36 	-- [sqliteconvert(1)](sqliteconvert.1.html), 
   37 	-- [sqlite2dot(1)](sqlite2dot.1.html), and
   38 	-- [sqlite2html(1)](sqlite2html.1.html).
   39 	-- The first, [sqliteconvert(1)](sqliteconvert.1.html), is
   40 	-- simply a shell script that pulls together the latter two.
   41 	"1. Tools" INTEGER NOT NULL,
   42 	-- The file generating this text is [test.sql.html].
   43 	-- You can see how I generate the links (Markdown-style) from
   44 	-- the comments.
   45 	"2. Input" INTEGER NOT NULL,
   46 	-- To see the source code, head to
   47 	-- [github.com/kristapsdz/sqliteconvert](https://github.com/kristapsdz/sqliteconvert)
   48 	-- and check it out yourself.
   49 	-- It consists of the (minimal) SQLite parser and its output
   50 	-- modes.
   51 	"3. Source Code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
   52 	-- To see a larger example, visit [schema.html].
   53 	-- This is created from the
   54 	-- [Gamelab](http://www.kcons.eu/gamelab) schema by using the
   55 	-- default 
   56 	-- [sqliteconvert(1)](sqliteconvert.1.html) invocation.
   57 	"4. Larger Example" TEXT,
   58 	/* Note our foreign key... */
   59 	FOREIGN KEY ("2. Input") REFERENCES "SYNTAX"("1. Comments"),
   60 	-- This should be discarded.
   61 	unique ("1. Tools")
   62 );
   63 
   64 /*
   65  * In this ``table'', I show how to document your SQLite schema so that
   66  * it shows up nicely---just like this here.
   67  * You can read about it in detail in
   68  * [sqlite2html(1)](sqlite2html.1.html).
   69 
   70  * On the other hand, you can just infer all this from [test.sql.html].
   71  */
   72 CREATE TABLE SYNTAX (
   73 	-- The comments themselves can be in SQLite single-line format
   74 	-- (two dashes), multi-line (slash-asterisk until another
   75 	-- slash-asterisk), or fancy multi-line (slash-asterisk until
   76 	-- another slash-asterisk, but ignoring ``*'' at the start of
   77 	-- individual lines).
   78 	"1. Comments" INTEGER NOT NULL,
   79 	-- sqliteconvert recognises ``CREATE TABLE'' statements and the
   80 	-- columns described by that, including foreign key references
   81 	-- and unique constraints.
   82 	-- At this time, the unique constraints are not used in any way.
   83 	"2. Schema" REAL NOT NULL,
   84 	-- Beyond the schema itself and the comments, you can have
   85 	-- generic links and link to tables/columns.
   86  	-- Quotes and dashes are also nice-ified.
   87 	"3. Specials" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
   88 );
   89 
   90 -- Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
   91 -- nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
   92 -- volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation
   93 -- ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo
   94 -- consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate
   95 -- velit esse molestie consequat, vel illum dolore eu feugiat nulla
   96 -- facilisis at vero eros et accumsan et iusto odio dignissim qui
   97 -- blandit praesent luptatum zzril delenit augue duis dolore te feugait
   98 -- nulla facilisi.
   99 
  100 CREATE TABLE Lorem (
  101 	-- Nam liber tempor cum soluta nobis eleifend option congue
  102 	-- nihil imperdiet doming id quod mazim placerat facer possim
  103 	-- assum. Typi non habent claritatem insitam; est usus legentis
  104 	-- in iis qui facit eorum claritatem.
  105 	col1 TEXT NOT NULL,
  106 	-- Investigationes demonstraverunt lectores legere me lius quod
  107 	-- ii legunt saepius.
  108 	col2 TEXT NOT NULL REFERENCES SYNTAX("1. Comments"),
  109 	-- Claritas est etiam processus dynamicus, qui sequitur
  110 	-- mutationem consuetudium lectorum. Mirum est notare quam
  111 	-- littera gothica, quam nunc putamus parum claram, anteposuerit
  112 	-- litterarum formas humanitatis per seacula quarta decima et
  113 	-- quinta decima.
  114 	col3 INTEGER NOT NULL DEFAULT(0),
  115 	-- Eodem modo typi, qui nunc nobis videntur parum clari, fiant
  116 	-- sollemnes in futurum.
  117 	col4 INTEGER NOT NULL,
  118 	-- And lastly, here's the primary key.
  119 	id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  120 );