CATS Developer Documentation
Database Structure
See also the WIKI page on CATS Developer documentation.
It tends to be more up to date than this page, but is still incomplete.
ANSWERS
One record per possible answer
- a_id: Primary key, autoincrement, integer
- q_id: Question for this answer, foreign key to QUESTIONS
- answer: text to be shown
- correct: Flag, if the answer is correct (1) or not (0)
ANSWERS_INCORRECT
One record per incorrect answer in any test, for statistic purposes
- lp_id: Foreign key to LEARNPROGRESS, references the test in question
- a_id: Foreign key to ANSWERS, references the incorrect answer.
LEARNPROGRESS
LEARNPROGRESS stores one record for each test which is done. Primary key is "lp_id" (autoincrement), "user_id" and "root"
refer to a USER record. Other columns:
- date: Timestamp of the test
- t_id: Foreign key to TOPICS, describes the kind of test which has been made.
- number: The number of questions of this test. There is a known bug that this sometimes is 0
- correct: The number of correctly answered questions. Known bug: this is sometimes the negative number of questions
- wrong: The number of false answers in the test
- percentage: Redundant column, should not be used...
- uploaded: Flag describing whether the test result has already been uploaded into the main CAcert database. 1 for "uploaded", NULL for "not uploaded".
QUESTIONS
One record per possible question
- q_id: Primary key, autoincrement, integer
- qt_id: Foreign key to QUESTIONTYPE, type (single selection, multi-selection, ...) of the question
- t_id: Foreign key to TOPICS, references the type of test this question belongs to.
- question: Text of the question. As a convention the question starts with the id of the "master question" in square brackets
(or round ones for "fill in the blanks" questions) to help referencing questions for debugging purposes.
- active: Flag if the question can be used in tests, 1 for yes, 0 for no
- description: Flag if the question has a "detailed description" (1) or not (0)
- ref_q_id: References another question as "master question", currently this is the english version of the question for a translated question.
QUESTIONTYPE
For backward compatibility only, do not use anymore!
This table lists the different kind of questions.
Currently the following types are supported:
- single selection (1): exactly one of the answers is correct.
- multiple selection (2): one or more of the answers may be correct. As a convention the number of correct answers is given in the text of the question.
- true / false (3): Single selection with "true" and "false" as possible answers.
- "fill in the blanks" (4): A text with "blanks" (marked by angle brackets with the correct answer). All answers are shown in a listbox for every blank.
Note: The definition of this table does not support adding of new user interface languages very well,
since every new language needs a new column in this table. The table should be retired soon and replaced with another one which supports
adding UI languages without modification of database structure!
QUESTIONTYPE_V2
Replacement for QUESTIONTYPE-table, which supports adding new languages dynamically
- qt_id: Type of question. the following types are supported:
- single selection (1): exactly one of the answers is correct.
- multiple selection (2): one or more of the answers may be correct. As a convention the number of correct answers is given in the text of the question.
- true / false (3): Single selection with "true" and "false" as possible answers.
- "fill in the blanks" (4): A text with "blanks" (marked by angle brackets with the correct answer). All answers are shown in a listbox for every blank.
- lang: Language of the text, as ISO 639-1 code, see Wikipedia on ISO 639-1.
- qt_desc: Translated description of the question type
QUESTION_DESCRIPTION
An optional explanation for a question, which is shown during the debriefing of a test.
- q_id: Primary key, foreign key to QUESTIONS.
- description: Text to be shown
STATISTICS
One (or no) record per question, for statistic purposes
- stat_id: Primary key, autoincrement, integer
- q_id: Foreign key to QUESTIONS, Unique???
- count: Number of times the question has been asked during a test
TOPIC_TYPE
Type of a test, "what is the test good for". Corresponds to CATS_TYPE on the main database, but matching is done by text.
One TOPIC_TYPE entry usually referenced by one or more (one for each supported language) entries in TOPICS
- type_id: Primary key, autoincrement, integer
- text: The textual name of the test type. This matches CATS_TYPE.type_text in the main database.
TOPICS
One record per kind of test. Corresponds to CATS_VARIANT on the main database
- t_id: Primary key, autoincrement, integer
- topic: The textual name of the test. This matches CATS_VARIANT.test_text on the main database
- active: 1 if the test can be done by users
- numOfQu: Number of questions per test
- lang: Language of the test, currently only used for information
- type_id: References TOPIC_TYPE.type_id
USER
Table USER contains the user records for the test. A user record is related to one certificate which is used for login.
The primary key is the combination of "user_id" (serial number of the certificate) and "root" (issuer of the certificate).
The only other column currently in use is "admin" which is set to 1 for users with administrative privileges.
USER_ADDRESS
Currently not used