Database
Before we get into the app code, I want to review how the database is set up. Keeping the database in mind will make things easier when we are discussing some of the application logic.
Database Diagram

There are four tables.
template, placeholder, replacement, and generated. Templates is the main table with a foreign key (1:n) to each of the other tables. Replacement has an additional foreign key (1:n) with the placeholder table.
The ddl to create the tables is in the query folder, in the database_maintenance.py file.
template
1 2 3 4 5 |
template_id int id number for the template template_name varchar name of the template template_file blob Microsoft Word Template deleted int did user ask to delete template file modify_at timestamp date time row was last updated |
placeholder
1 2 3 4 5 6 7 |
placeholder_id int id number for the placeholder template_id int foreign key to template.template_id placeholder_type varchar type of placeholder, valid are static, inline, list, bullet placeholder_name varchar name of placeholder placeholder_order int order the placeholder appears in template deleted int did user ask for the placeholder to be deleted modify_at timestamp date time row was last updated |
Leave a Reply