Database structure
FKMTime uses PostgreSQL database to store all the data. The database structure is shown below.
We use Prisma ORM to interact with the database. You can read more about Prisma here.
We are using camelCase in our code, although the database is using snake_case. Prisma is taking care of the conversion using @map
.
We are using UUIDs as primary keys for all tables.
Tables
Competition
There is one record in this table. It stores the competition settings, WCIF and other general data. Most of the data in this table is inserted during the import from the WCA website.
id
- unique identifiername
- competition namewcaId
- WCA competition IDsendingResultsFrequency
- enum, stores how often the results are sent to the WCA Live/CubingContestscountryIso2
- country ISO2 codeshouldUpdateDevices
- boolean, if the devices should be updated with new releasesshouldChangeGroupsAutomatically
- boolean, if the groups should be changed automaticallywifiSsid
- wifi SSID, that FKMTime devices will be using to connect to micro-connectorwifiPassword
- wifi passwordmdns
- boolean, whether mDNS should be used to discover devicesipAddress
- IP address of the server (if mDNS is not used)port
- port of the server (if mDNS is not used)secure
- boolean, if the server is using SSL (if mDNS is not used)wcif
- JSON, stores public WCIF of the competitionscoretakingToken
- token taken from WCA Live for entering resultscubingContestToken
- token taken from CubingContests for entering resultsscoretakkingTokenExpiresAt
- date, after this date token may have expired (7 days after saving the new token)
UnofficialEvent
This table stores unofficial events that are held during the competition.
id
- unique identifiereventId
- id taken frombackend/src/events.ts
wcif
- event data in WCIF format (stored as JSON)createdAt
- date of creationupdatedAt
- date of last update
Room
This table stores rooms taken from WCIF during import.
id
- unique identifiername
- room namecolor
- room colorcurrentGroupId
- id of the group that takes place currently in this room, can be nullcreatedAt
- date of creationupdatedAt
- date of last update
Device
This table stores data about all FKMTime devices that are connected to the system.
id
- unique identifiername
- device name, can be changedespId
- ESP32 device IDtype
- device type (enum)batteryPercentage
- battery percentage, updated automaticallyroomId
- RoomcreatedAt
- date of creationupdatedAt
- date of last update
User
All user accounts are stored in this table, both FKMTime and WCA accounts added to the system.
id
- unique identifierpassword
- hashed password, only available for FKMTime accountsusername
- username, only available for FKMTime accountsrole
- user role (enum)fullName
- full name of the userwcaUserId
- WCA user ID, only available for WCA accountsisWcaAdmin
- boolean, if the user is WCA admin, only available for WCA accountswcaAccessToken
- WCA access token, only available for WCA accountscreatedAt
- date of creationupdatedAt
- date of last update
QuickAction
This table stores quick actions that can be used to simplify resolving incidents process by delegats.
id
- unique identifiername
- action namecomment
- comment that will be added to the attemptgiveExtra
- boolean, if the action should give extra attemptisShared
- boolean, if the action is shared between all usersuserId
- User that created the actioncreatedAt
- date of creationupdatedAt
- date of last update
Person
This table stores data about competitors and staff members. Most data are inserted during import and sync.
id
- unique identifierregistrantId
- WCA registrant IDname
- full namewcaId
- WCA IDcountryIso2
- country ISO2 codegender
- gendercanCompete
- boolean, if the person can competebirthdate
- date of birth, null for all persons except newcomerscheckedInAt
- date of check-incardId
- assigned card ID
StaffActivity
This table stores data about all staff/competing activities, pre-assigned and performed during the competition.
id
- unique identifierpersonId
- PersondeviceId
- Device (can be null)isAssigned
- boolean, if the activity is pre-assignedisPresent
- boolean, if the person performed the activitygroupId
- WCIF group IDrole
- role of the person in the group (enum)createdAt
- date of creationupdatedAt
- date of last update
Result
This table stores all results that are entered during the competition.
id
- unique identifierpersonId
- PersoneventId
- event ID, taken frombackend/src/events.ts
roundId
- round ID in WCIF formatisDoubleChecked
- boolean, if the result was already double-checkedcreatedAt
- date of creationupdatedAt
- date of last update
Attempt
This table is the biggest table, it stores all attempts that are entered during the competition.
id
- unique identifiersessionId
- unique identifier generated by FKMTime deice that prevents from entering the same attempt twiceresultId
- ResultattemptNumber
- number of the attemptreplacedBy
- id of the attempt that replaced this one (if extra attempt was granted)comment
- comment for the attempt, added by the delegatetype
- AttemptType, see belowstatus
- AttemptStatus, see belowvalue
- time in centisecondsoriginalTime
- exact time taken from stackmat, in milisecondsjudgeId
- Person that judged the attemptdeviceId
- Device that was used to enter the attempt (can be null if attempt was entered manually)solvedAt
- date of finishing the solvecreatedAt
- date of creationupdatedAt
- date of last update
Enums
AttemptType
STANDARD_ATTEMPT
- applied for all normal attemptsEXTRA_ATTEMPT
- applied for extra attempts
AttemptStatus
STANDARD
- applied for all normal attemptsUNRESOLVED
- applied for incidents that need to be resolvedRESOLVED
- applied for resolved incidents, without extraEXTRA_GIVEN
- applied for resolved incidents, with extra
UserRole
ADMIN
- user with all permissionsSTAFF
- user with permissions to check-in, assigning cards and viewing the results
DeviceType
STATION
- device that is used to enter resultsATTENDANCE_SCRAMBLER
- staff attendance device for scramblersATTENDANCE_RUNNER
- staff attendance device for runners
StaffRole
COMPETITOR
- competitorJUDGE
- judgeRUNNER
- runnerSCRAMBLER
- scrambler
SendingResultsFrequency
AFTER_SOLVE
- selected by default, results are sent to WCA Live/Cubing contestsafter each solveEVERY_5_MINUTES
- results are sent to WCA Live/Cubing Contests every 5 minutesNEVER
- results are not sent to WCA Live/Cubing Contests