Last active
May 12, 2026 17:35
-
-
Save isocroft/bf7bac3484a9fd83d7ab7b77031df71b to your computer and use it in GitHub Desktop.
A database schema for an event plan and management app that is Meetup-like using either MySQL, SQLite or PostgreSQL as primary database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- MySQL v8.0.16 | |
| -- PostgresSQL v16.9.2 | |
| CREATE DATABASE IF NOT EXISTS `test` | |
| DEFAULT CHARACTER SET utf8 -- utf8mb4 | |
| DEFAULT COLLATE utf8_general_ci; -- utf8mb4_unicode_ci | |
| SET default_storage_engine = INNODB; | |
| SET time_zone = '+00:00'; -- I don't want MySQL to convert to current database session timezone | |
| CREATE TABLE organizers ( | |
| id bigint NOT NULL, | |
| email varchar(90) NOT NULL, | |
| PRIMARY KEY(id) | |
| ); | |
| CREATE TABLE events ( | |
| id bigint NOT NULL, | |
| venue text, | |
| headline varchar(200), | |
| registration_type enum('free', 'paid') NOT NULL DEFAULT 'free', | |
| organizer_id bigint NOT NULL, | |
| PRIMARY KEY(id), | |
| FOREIGN KEY (organizer_id) REFERENCES organizers(id) ON DELETE CASCADE | |
| ); | |
| CREATE TABLE event_talks ( | |
| event_id bigint NOT NULL, | |
| talk_id bigint NOT NULL, | |
| PRIMARY KEY (event_id, talk_id), | |
| FOREIGN KEY (talk_id) REFERENCES talks(id) ON DELETE CASCADE, | |
| FOREIGN KEY (event_id) REFERENCES events(id) ON DELETE CASCADE | |
| ); | |
| CREATE TABLE speakers ( | |
| id bigint NOT NULL, | |
| name varchar(255) NOT NULL, | |
| bio text, | |
| email varchar(90) NOT NULL, | |
| photo_url varchar(255), | |
| PRIMARY KEY (id), | |
| UNIQUE(email) | |
| ); | |
| CREATE TABLE talks ( | |
| id bigint NOT NULL, | |
| title varchar(255) NOT NULL, | |
| full_description mediumtext, | |
| abstract text, | |
| speaker_id bigint NULL, | |
| duration int NOT NULL, -- useful data redundancy for `start_time` and `end_time` in schedules table | |
| location_id bigint NULL, | |
| PRIMARY KEY (id), | |
| FOREIGN KEY (speaker_id) REFERENCES speakers(id) ON DELETE SET NULL, | |
| FOREIGN KEY (location_id) REFERENCES locations(id) ON DELETE SET NULL | |
| ); | |
| CREATE TABLE attendees ( | |
| id bigint NOT NULL, | |
| name varchar(255) NOT NULL, | |
| email varchar(90) NOT NULL, | |
| registration_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
| PRIMARY KEY (id), | |
| UNIQUE(email) | |
| ); | |
| CREATE TABLE attendee_accounts ( | |
| id bigint NOT NULL, | |
| email varchar(90) NOT NULL, -- useful data redundancy | |
| password varchar(180) NOT NULL, | |
| PRIMARY KEY(id), | |
| FOREIGN KEY (id) REFERENCES attendees(id) ON DELETE CASCADE | |
| ); | |
| CREATE TABLE organizer_accounts ( | |
| id bigint NOT NULL, | |
| email varchar(90) NOT NULL, -- useful data redundancy | |
| password varchar(180) NOT NULL, | |
| PRIMARY KEY(id), | |
| FOREIGN KEY (id) REFERENCES organizers(id) ON DELETE CASCADE | |
| ); | |
| CREATE TABLE schedules ( | |
| id bigint NOT NULL, | |
| talk_id bigint NOT NULL, | |
| start_time TIMESTAMP NOT NULL, | |
| speaker_id bigint NULL, | |
| end_time TIMESTAMP NOT NULL, | |
| location_id bigint NULL, | |
| PRIMARY KEY (id), | |
| FOREIGN KEY (talk_id) REFERENCES talks(id) ON DELETE CASCADE, | |
| FOREIGN KEY (speaker_id) REFERENCES speakers(id) ON DELETE SET NULL, | |
| FOREIGN KEY (location_id) REFERENCES locations(id) ON DELETE SET NULL | |
| ); | |
| CREATE TABLE registrations ( | |
| id bigint NOT NULL, | |
| attendee_id bigint NOT NULL, | |
| talk_id bigint NOT NULL, | |
| registered_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
| PRIMARY KEY (id), | |
| FOREIGN KEY (attendee_id) REFERENCES attendees(attendee_id) ON DELETE CASCADE, | |
| FOREIGN KEY (talk_id) REFERENCES talks(talk_id) ON DELETE CASCADE, | |
| UNIQUE(attendee_id, talk_id) -- prevents duplicate registration | |
| ); | |
| CREATE TABLE locations ( | |
| id bigint NOT NULL, | |
| name varchar(200) NOT NULL, | |
| code char(6) NOT NULL, | |
| PRIMARY KEY (id), | |
| UNIQUE(code) | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.