[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1 How to add new dataset

To define a dataset we have to introduce its name (function init_dataset and optionaly describe its data source or sources (function add_ds_source). Dataset tables are described by calls to function add_ds_table where parameters are dataset name, priority in which tables are listed in tutorail questions, table name and the list of its column names (attributes).

Example:

 
SELECT init_dataset ('computer_store');
SELECT add_ds_source('computer_store', 2010,
       'http://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store');
SELECT add_ds_table ('computer_store', 1, 'manufacturers', 'code, name');
SELECT add_ds_table ('computer_store', 2, 'products',
                     'code, name, price, manufacturer');

For each problem we can formulate one or more quesitions and one or more answers (sql queries). Within a dataset each problem is described by a unique identification number (secon parameter of the function insert_problem) followed by its point rating.

 
-- dataset name, internal problem_id, points, category
-- (currently unused)
SELECT insert_problem ('computer_store', 10, 1, 'select');

-- dataset name, internal problem id, order, language, question text
SELECT insert_question('computer_store', 10, 1, 'en',
       'Select the names and the prices of all the products 
        in the store.');

--  dataset name, internal dataset id, order, language, sql answer
SELECT insert_answer  ('computer_store', 10, 1,
                       'SELECT name FROM products;');

Tutoriual questions can be translated to other languages.

 
-- Problem defines id, point rating and category
SELECT insert_problem ('computer_store', 30, 2, 'select');
SELECT insert_question('computer_store', 30, 1, 'en',
       'Select the names of the products with a price less
        than or equal to $200.');
SELECT insert_answer  ('computer_store', 30, 1,
       'SELECT name FROM products WHERE price <= 200;');

-- Czech translation of problem id 30.  Answers (SQL code) are shared
-- among all translations
SELECT insert_question('computer_store', 30, 1, 'cs',
                       'Vypište jména všech produktů, jejichž cena
                        je menší nebo rovna 200 dolarů.');

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Ales Cepek on May 25, 2014 using texi2html 1.82.