public

Database Relations

Entity Relationship Diagram ERD

An entity relationship diagram (ERD) shows the relationships of entity and sets stored in a database.

An entity in this context is a table, this table contains a set of attributes, they can be of any data structure (INT, TEXT, …).

An entity can have several relations to other entities. Those relations are represented with “crow foots”

Relationships cardinality

Relationships have a cardinality, normally they have two indicators that are shown on both sides of the line.

  1. One end of the line, refers to the max number of times that an instance of one entity can be associated with instances in the related entity. It can be one, many or none

  2. The second, describes the min number of times one instance can be related to others. It can be zero or mandatory

The combination of those two indicators create relations, you can get more information here

alt text

Relations

Events

Events will be the accumulation of the following tables :

This part of the database takes care of schools activities with time.

The event table contains the following relations:


The event_user contains the associations between events and users. This will contain information on which users are registered to which event. An event can have multiple users and a user can have multiple events, this way being a many to many relationship.


The registration table contains all objects/activities that need registration. Having the following relations:


The registration_user table is a relationship many to many between registration and user. This table contains all users that are registered to an event.


Objects

Object will be the accumulation of the following tables :

This part of the database defines the structure of the content.

The object table contains the following relations:


The object_child table contains the encapsulation of objects. An object can have multiple children and a child must have one object parent. Note that one parent can’t be associated two times to children with the same key. This table contains the following relationships to the object table:

Both child and parent must have at least one association to the object table, and the object table can have multiple relations with the object_child table.

Example:

Campus madeira is a parent object of piscine-go, therefore the later one is the child.

But piscine-go can be the parent object of all the quest, exams and raids (those being the child objects). And so on… creating a finite cycle.


Users

Users will be the accumulation of the following tables:


The role table contains permission roles for each user.


The user_role contains information on which users are associated to which role. A user can have multiple roles and a role can be associated to multiple users.


The group table is the link between projects or raids and a group of users. This table contains the following relations:


The group_user table contains the relation between groups and users. A group can have several users and so do the users.


The token table stores the tokens ids from the hasura authorization variables for each user. This table has no relation between other tables.


The record table takes care of students records (bans). All relations in this table are with the table user.


The transaction table takes care of rewarding the user, by accumulating the user’s xp , up and down (you can see more information about those types in the database-structure.md). This table contains the following relations:


Results

Results will be the accumulation of the following tables:

This part of the database defines the users/students progress in the school.

The audit table contains all information related to the audit system and it is one of the ways of obtaining results. This table contains the following relations:


The match table is another way of obtaining a result. This table is used in bonus exercises to match two students. The following relations are established:


The progress table is the reflection of user’s activity on specific path: registration to an event related, commitment to a group associated to this path, generation of result expected to validate a progress on this path.


The result table keeps the track of students result. The following relations are established: