wiki:RelationalDesign

Version 4 (modified by 236024, 4 days ago) ( diff )

--

Relational Design

This page documents the relational design for BEST Skopje Hub, based on ERModel_v10. 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.

Descriptive representation of the relational schema

students(
    student_index, first_name, last_name, faculty, field_of_studies,
    year_of_studies, birthday, email, phone_number,
    PK(student_index)
)

members(
    student_index,
    PK(student_index),
    FK(student_index) -> students(student_index)
)

observers(
    student_index,
    PK(student_index),
    FK(student_index) -> members(student_index)
)

young_members(
    student_index, mentor_index,
    PK(student_index),
    FK(student_index) -> members(student_index),
    FK(mentor_index) -> full_members(student_index)
)

full_members(
    student_index,
    PK(student_index),
    FK(student_index) -> members(student_index)
)

alumni(
    student_index,
    PK(student_index),
    FK(student_index) -> members(student_index)
)

membership_stages(
    ms_id, ms_name,
    PK(ms_id),
    UNIQUE(ms_name)
)

has_stage(
    student_index, ms_id, valid_from, valid_to,
    PK(student_index, ms_id, valid_from),
    FK(student_index) -> members(student_index),
    FK(ms_id) -> membership_stages(ms_id)
)

organizational_functions(
    of_id, of_title,
    PK(of_id),
    UNIQUE(of_title)
)

board(
    of_id,
    PK(of_id),
    FK(of_id) -> organizational_functions(of_id)
)

non_board(
    of_id,
    PK(of_id),
    FK(of_id) -> organizational_functions(of_id)
)

function_mandates(
    student_index, of_id, mandate_year,
    PK(student_index, of_id, mandate_year),
    FK(student_index) -> full_members(student_index),
    FK(of_id) -> organizational_functions(of_id)
)

activity_types(
    at_id, at_name, at_description,
    PK(at_id),
    UNIQUE(at_name)
)

locations(
    l_id, l_name,
    PK(l_id),
    UNIQUE(l_name)
)

activity_sessions(
    as_id, at_id, l_id, as_start_time,
    PK(as_id),
    FK(at_id) -> activity_types(at_id),
    FK(l_id) -> locations(l_id)
)

related_to(
    as_id, ee_id,
    PK(as_id),
    FK(as_id) -> activity_sessions(as_id),
    FK(ee_id) -> event_editions(ee_id)
)

event_types(
    et_id, et_name, et_description,
    PK(et_id),
    UNIQUE(et_name)
)

event_editions(
    ee_id, et_id, ee_title, ee_start_time, ee_end_time,
    PK(ee_id),
    FK(et_id) -> event_types(et_id)
)

event_edition_locations(
    ee_id, l_id,
    PK(ee_id, l_id),
    FK(ee_id) -> event_editions(ee_id),
    FK(l_id) -> locations(l_id)
)

event_session_types(
    est_id, est_name, est_description,
    PK(est_id),
    UNIQUE(est_name)
)

event_sessions(
    ee_id, es_no, est_id, l_id, es_start_time, es_title, needed_no_volunteers,
    PK(ee_id, es_no),
    FK(ee_id) -> event_editions(ee_id),
    FK(est_id) -> event_session_types(est_id),
    FK(l_id) -> locations(l_id)
)

event_functions(
    ee_id, ef_no, ef_name,
    PK(ee_id, ef_no),
    FK(ee_id) -> event_editions(ee_id)
)

applications(
    application_id, student_index, ee_id, ef_no,
    motivational_letter, application_type, application_status,
    PK(application_id),
    FK(student_index) -> students(student_index),
    FK(ee_id) -> event_editions(ee_id),
    FK(ee_id, ef_no) -> event_functions(ee_id, ef_no)
)

participation(
    student_index, as_id, rsvp_status, rsvp_at, attendance_status,
    PK(student_index, as_id),
    FK(student_index) -> students(student_index),
    FK(as_id) -> activity_sessions(as_id)
)

announces_absence(
    student_index, as_id, reason, announced_at,
    PK(student_index, as_id),
    FK(student_index) -> members(student_index),
    FK(as_id) -> activity_sessions(as_id)
)

responsible_for(
    student_index, as_id,
    PK(student_index, as_id),
    FK(student_index) -> members(student_index),
    FK(as_id) -> activity_sessions(as_id)
)

volunteers(
    student_index, ee_id, es_no, volunteer_role,
    PK(student_index, ee_id, es_no),
    FK(student_index) -> members(student_index),
    FK(ee_id, es_no) -> event_sessions(ee_id, es_no)
)

companies(
    c_id, c_name, naframa_reference,
    PK(c_id)
)

cooperation(
    c_id, ee_id, cooperation_type,
    PK(c_id, ee_id),
    FK(c_id) -> companies(c_id),
    FK(ee_id) -> event_editions(ee_id)
)

In the physical PostgreSQL schema, application_id is implemented as an automatically generated identity value. It is still listed as the primary key of applications, but it does not have to be manually inserted in the data loading script.

The applications relation is used only when there is an actual application process. Public attendance for events such as Job Fair, and open registration-style attendance for events such as beBESTie, is not represented as an application in this phase. For Hackathon and BEST Course in Summer participation applications, the motivational_letter attribute represents the most important motivation/answer kept from an external application form.

The 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.

The weak entities from ERModel_v10 are represented with composite primary keys where they still depend on an owner entity. event_functions uses (ee_id, ef_no), and event_sessions uses (ee_id, es_no). Other concrete entities such as activity_sessions and event_editions use their own numeric identifiers.

The Locations entity is represented with locations. The relationship between EventEditions and Locations is represented with event_edition_locations.

The relationships has_stage, participation, announces_absence, responsible_for, volunteers, cooperation, related_to, holds_function, and the event-edition location relationship 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, takes_place_at, held_at, and mentorship are represented directly with foreign keys on the N-side relation.

DDL script for creating the database schema and objects

The 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.

schema_creation.sql

DML script for filling tables with data

The 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.

data_load.sql

Relational diagram

The relational diagram was exported from DBeaver after running schema_creation.sql in the assigned PostgreSQL database and opening the project schema diagram. The diagram uses crow-feet notation.

AI Use

AI was used during this phase as a consultation, drafting, and checking tool while preparing the relational design from the already completed ERModel_v10. The AI-assisted parts were reviewed against the existing ER model and project requirements before being included.

Full AI usage documentation: RelationalDesignAIUsage.

Attachments (3)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.