Changes between Initial Version and Version 1 of RelationalDesign


Ignore:
Timestamp:
08/28/26 21:33:21 (9 days ago)
Author:
236024
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RelationalDesign

    v1 v1  
     1= Relational Design =
     2
     3This page documents the relational design for BEST Skopje Hub, based on !ERModel_v09. The design uses partial transformation from the ER model into a PostgreSQL relational schema. Strong entities are mapped directly to relations, weak entities include the primary keys of their owner entities, specializations are mapped with one relation for the supertype and one relation for each subtype, and M:N relationships are mapped as separate relations.
     4
     5Some attribute names were adapted to SQL-friendly snake_case names. For example, the ER attribute `index` is represented as `student_index`, and the !EventEditions attributes `title`, `start`, and `end` are represented as `event_title`, `event_start_time`, and `event_end_time`.
     6
     7== Descriptive representation of the relational schema ==
     8
     9{{{
     10students(
     11    student_index, first_name, last_name, faculty, field_of_studies,
     12    year_of_studies, birthday, email, phone_number,
     13    PK(student_index)
     14)
     15
     16members(
     17    student_index,
     18    PK(student_index),
     19    FK(student_index) -> students(student_index)
     20)
     21
     22observers(
     23    student_index,
     24    PK(student_index),
     25    FK(student_index) -> members(student_index)
     26)
     27
     28young_members(
     29    student_index, mentor_index,
     30    PK(student_index),
     31    FK(student_index) -> members(student_index),
     32    FK(mentor_index) -> full_members(student_index)
     33)
     34
     35full_members(
     36    student_index,
     37    PK(student_index),
     38    FK(student_index) -> members(student_index)
     39)
     40
     41alumni(
     42    student_index,
     43    PK(student_index),
     44    FK(student_index) -> members(student_index)
     45)
     46
     47membership_stages(
     48    ms_name,
     49    PK(ms_name)
     50)
     51
     52has_stage(
     53    student_index, ms_name, valid_from, valid_to,
     54    PK(student_index, ms_name, valid_from),
     55    FK(student_index) -> members(student_index),
     56    FK(ms_name) -> membership_stages(ms_name)
     57)
     58
     59organizational_functions(
     60    of_title,
     61    PK(of_title)
     62)
     63
     64board(
     65    of_title,
     66    PK(of_title),
     67    FK(of_title) -> organizational_functions(of_title)
     68)
     69
     70non_board(
     71    of_title,
     72    PK(of_title),
     73    FK(of_title) -> organizational_functions(of_title)
     74)
     75
     76is_organizational_function(
     77    student_index, of_title, mandate,
     78    PK(student_index, of_title, mandate),
     79    FK(student_index) -> full_members(student_index),
     80    FK(of_title) -> organizational_functions(of_title)
     81)
     82
     83activity_types(
     84    at_name, at_description,
     85    PK(at_name)
     86)
     87
     88activity_sessions(
     89    at_name, as_start_time, as_location,
     90    PK(at_name, as_start_time, as_location),
     91    FK(at_name) -> activity_types(at_name)
     92)
     93
     94related_to(
     95    at_name, as_start_time, as_location, et_name, event_title, event_start_time,
     96    PK(at_name, as_start_time, as_location),
     97    FK(at_name, as_start_time, as_location) -> activity_sessions(at_name, as_start_time, as_location),
     98    FK(et_name, event_title, event_start_time) -> event_editions(et_name, event_title, event_start_time)
     99)
     100
     101event_types(
     102    et_name, et_description,
     103    PK(et_name)
     104)
     105
     106event_editions(
     107    et_name, event_title, event_start_time, event_end_time,
     108    PK(et_name, event_title, event_start_time),
     109    FK(et_name) -> event_types(et_name)
     110)
     111
     112event_edition_locations(
     113    et_name, event_title, event_start_time, location,
     114    PK(et_name, event_title, event_start_time, location),
     115    FK(et_name, event_title, event_start_time) -> event_editions(et_name, event_title, event_start_time)
     116)
     117
     118event_session_types(
     119    est_name, est_description, needed_no_volunteers,
     120    PK(est_name)
     121)
     122
     123event_sessions(
     124    et_name, event_title, event_start_time, est_name, es_start_time, location, es_title,
     125    PK(et_name, event_title, event_start_time, est_name, es_start_time, location),
     126    FK(et_name, event_title, event_start_time) -> event_editions(et_name, event_title, event_start_time),
     127    FK(est_name) -> event_session_types(est_name)
     128)
     129
     130core_team_functions(
     131    et_name, event_title, event_start_time, function_name,
     132    PK(et_name, event_title, event_start_time, function_name),
     133    FK(et_name, event_title, event_start_time) -> event_editions(et_name, event_title, event_start_time)
     134)
     135
     136applications(
     137    application_id, student_index, et_name, event_title, event_start_time,
     138    function_name, motivational_letter, application_type, application_status,
     139    PK(application_id),
     140    FK(student_index) -> students(student_index),
     141    FK(et_name, event_title, event_start_time) -> event_editions(et_name, event_title, event_start_time),
     142    FK(et_name, event_title, event_start_time, function_name) -> core_team_functions(et_name, event_title, event_start_time, function_name)
     143)
     144
     145participation(
     146    student_index, at_name, as_start_time, as_location,
     147    rsvp_status, rsvp_at, attendance_status,
     148    PK(student_index, at_name, as_start_time, as_location),
     149    FK(student_index) -> students(student_index),
     150    FK(at_name, as_start_time, as_location) -> activity_sessions(at_name, as_start_time, as_location)
     151)
     152
     153announces_absence(
     154    student_index, at_name, as_start_time, as_location, reason, announced_at,
     155    PK(student_index, at_name, as_start_time, as_location),
     156    FK(student_index) -> members(student_index),
     157    FK(at_name, as_start_time, as_location) -> activity_sessions(at_name, as_start_time, as_location)
     158)
     159
     160responsible_for(
     161    student_index, at_name, as_start_time, as_location,
     162    PK(student_index, at_name, as_start_time, as_location),
     163    FK(student_index) -> members(student_index),
     164    FK(at_name, as_start_time, as_location) -> activity_sessions(at_name, as_start_time, as_location)
     165)
     166
     167volunteers(
     168    student_index, et_name, event_title, event_start_time,
     169    est_name, es_start_time, location, volunteer_role,
     170    PK(student_index, et_name, event_title, event_start_time, est_name, es_start_time, location),
     171    FK(student_index) -> members(student_index),
     172    FK(et_name, event_title, event_start_time, est_name, es_start_time, location) -> event_sessions(et_name, event_title, event_start_time, est_name, es_start_time, location)
     173)
     174
     175companies(
     176    c_id, c_name, naframa_reference,
     177    PK(c_id)
     178)
     179
     180cooperation(
     181    c_id, et_name, event_title, event_start_time, cooperation_type,
     182    PK(c_id, et_name, event_title, event_start_time),
     183    FK(c_id) -> companies(c_id),
     184    FK(et_name, event_title, event_start_time) -> event_editions(et_name, event_title, event_start_time)
     185)
     186}}}
     187
     188The specialization of students into members and then into observers, young members, full members, and alumni is represented through subtype tables whose primary keys are also foreign keys. `young_members` also contains `mentor_index`, which represents the mentorship relationship directly as a foreign key to `full_members`.
     189
     190The weak entities from the ER model are represented using composite primary keys. `activity_sessions` includes the key of `activity_types`. `event_editions` includes the key of `event_types`. `event_sessions` includes the composite key of `event_editions`, the key of `event_session_types`, and its partial key attributes `es_start_time` and `location`. `core_team_functions` includes the composite key of `event_editions` and its partial key `function_name`.
     191
     192The multivalued `locations` attribute of !EventEditions is transformed into the separate relation `event_edition_locations`.
     193
     194The relationships `has_stage`, `participation`, `announces_absence`, `responsible_for`, `volunteers`, `cooperation`, `related_to`, and `is` are represented as relations because they either have M:N cardinality, their own attributes, or are clearer without nullable foreign-key columns. The relationship `related_to` is represented separately because only some activity sessions are connected to event editions. The relationship `applies_with` is represented with the foreign key `student_index` in `applications`, because each application belongs to one student. The N:1 relationships `for_function`, `for_participation`, and `mentorship` are represented directly with foreign keys on the N-side relation.
     195
     196== DDL script for creating the database schema and objects ==
     197
     198The DDL script recreates the official `project` schema and all database objects. It first drops the existing `project` schema if it exists, then creates the schema, tables, primary keys, foreign keys, and checks.
     199
     200[attachment:schema_creation.sql schema_creation.sql]
     201
     202== DML script for filling tables with data ==
     203
     204The DML script recreates realistic sample data for all relations. It clears the current contents of the tables and inserts connected sample data for students, members, membership stages, activity sessions, event-related activity links, event editions, event sessions, applications, companies, volunteering, mentorship, attendance/RSVP, announced absences, and organizational functions.
     205
     206[attachment:data_load.sql data_load.sql]
     207
     208== Relational diagram ==
     209
     210The relational diagram will be exported from DBeaver after running `schema_creation.sql` in the assigned PostgreSQL database and opening the `project` schema diagram. The diagram will use crow-feet notation and be exported as `relational_schema.jpg`.
     211
     212== AI Use ==
     213
     214AI was used during this phase as a consultation, drafting, and checking tool while preparing the relational design from the already completed !ERModel_v09. The AI-assisted parts were reviewed against the existing ER model and project requirements before being included.
     215
     216Full AI usage documentation: [wiki:RelationalDesignAIUsage RelationalDesignAIUsage].