First, we show how the database would be described traditionally - using the classes of the models Django package.
Notes:
To create a database description, you need to define its classes:
Polls_db - the main database class for the survey site application. The main database class is defined as a subclass of HTdb, which in HTMS serves as a superclass for application databases (there may be several).
Polls, Answers, Comments, Visiters - classes for database tables. Table - one of the main classes of HTMS, serves as a superclass for classes of specific tables.
HTMS creates (or opens an existing) database directly when the site program is running. Relevant options:
When there is a new database created during the initialization of the instance of the HTdb subclass, it is necessary to define the actual structure (scheme) at the logical level. This is done once at the first launch of the site, but, unlike the ORM technology, in the program code of the site itself.
The execution of this code will lead to the formation of the database structure and the creation of the corresponding files on the server, if the database is new.
If the database has already been created, to work with it you only need to create instances of table classes:
Obviously, the formalization of the data scheme at the logical level in HTMS and ORM are similar, but there are a number of fundamental differences.
In HTMS, attributes and data types are defined as a single space; in ORM, they are bound to separate tables.
The whole set of database attributes in ORM is created "additively", as models are defined, therefore they cannot be changed programmatically, but in HTMS - for the entire database as a whole, and you can add or remove them in the application without migration.
The attributes for each individual model in ORM are static, and in HTMS they are dynamic. Tabular structures in HTMS are defined as projections of a single attribute set - it is simpler and clearer than in ORM. The site algorithms on HTMS can provide options for changing the original database structure, for example, adding new attributes or deleting existing ones, which is impossible in principle in ORM technology .
Note that HTMS technology, if applied in the Django framework, only expands its capabilities and does not require the abandonment of the use of ORM. For example, Django’s entire excellent authentication system, based on the models and the User class (from the django.contrib.auth.models module), can be used. Therefore, in reality, a Django site with HTMS will usually be “multi-model”, that is, one part of the overall database will be purely relational, the other tabular-network.