-
Notifications
You must be signed in to change notification settings - Fork 4
Models and Database
FAF site is using a relational database MySQL. MySQL was chosen due to its availability on university servers. Django models represent the data of the application. Raw SQL queries are not used at all and are also not welcome (think twice before hardcoding the query, maybe there is a way to do it using native ORM). Nevertheless MySQL is a relational database and most of our tables are conceptually relational, there are some specific tables that simulate a non-relational database.
The database consists of tables created by default Django (django_session), Django basic apps (auth_user_groups) and those created from the models.
Conceptually separated into 2 entities: Courses and Users.
Course model/table is rather trivial. It keeps all the information about a course taught at FAF. This table has a many-to-many relationship to User table.
User model stores basic information about a university person. At the moment there were determines 3 types of users -- students, professors and alumni. All those types of users are stored altogether in the Users table. Their type property is not stored in this table. This property is create in the UserMetaType table, where we define the key name for the metatype, the type of the data (String, URL, TextArea) and extra data in case metatype is multiple (has choices).
For example here is a tuple from the table UserMetaType:
key: type, type: Multiple Choice, Multiple: True, Data: ["student", "alumni", "professor"]
After defining the necessary meta types, we can proceed to defining tuples from UserMeta table. UserMeta model has 2 (foreign keys)[https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey] to User table and to UserMetaType table. Basically it maps our users with our properties. As an example take user with name 'Vasilica' that has meta of type 'type' and the value is 'student'.
In that way we can add new proprieties easily, without adding new columns to existing tables. :)
To be documented
To be documented
To be documented