Tables¶
As stated previously, the database structure is defined in the database.models
module. Currently, it is composed of the following tables.
Document¶
- database.models.Document (document)
Documents used for the RAG
Columns:
id*
INTEGER
→ source_id
INTEGER?
text
TEXT
embedding
VECTOR(1536)?
language
VARCHAR(3)?
tag
VARCHAR(255)?
url
TEXT
created_at
DATETIME
modified_at
DATETIME
Constraints:
FOREIGN KEY (source.id → source_id)
PRIMARY KEY (id)
Indexes:
text_tsv (text)
Question¶
- database.models.Question (question)
Question used for Autocomplete, answers are stored in the Document table.
Columns:
id*
INTEGER
→ answer_id
INTEGER
→ source_id
INTEGER?
text
TEXT
embedding
VECTOR(1536)?
language
VARCHAR(3)?
tag
VARCHAR(255)?
url
TEXT
created_at
DATETIME
modified_at
DATETIME
Constraints:
FOREIGN KEY (document.id → answer_id)
FOREIGN KEY (source.id → source_id)
PRIMARY KEY (id)
Indexes:
idx_text_gin (text)
Source¶
- database.models.Source (source)
Source of the data stored in Document and Question tables. It can be URL, file path, user ID, etc.
Columns:
id*
INTEGER
url*
TEXT
Constraints:
PRIMARY KEY (id)
UNIQUE (url)