Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keidsid/bsa-2024-db-sql
Binary Studio Academy 2024 "JavaScript: Database and SQL" Lecture Homework
https://github.com/keidsid/bsa-2024-db-sql
binary-studio-academy bsa2024 mermaidjs psql sql
Last synced: 27 days ago
JSON representation
Binary Studio Academy 2024 "JavaScript: Database and SQL" Lecture Homework
- Host: GitHub
- URL: https://github.com/keidsid/bsa-2024-db-sql
- Owner: KeidsID
- License: mit
- Created: 2024-07-23T07:58:52.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-07-26T12:06:21.000Z (3 months ago)
- Last Synced: 2024-10-11T09:04:30.167Z (27 days ago)
- Topics: binary-studio-academy, bsa2024, mermaidjs, psql, sql
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BSA 2024 DB SQL
Binary Studio Academy "Javascript: Database and SQL" Lecture Homework.
- [Data Definiton](sql/data.sql)
- [Queries](sql/queries/)## Entity Relationship Diagram
NOTE: Every tables has `created_at` and `updated_at` columns.
```mermaid
---
title: Simple Entity Relationship Diagram
---
erDiagram
users }o--|{ favorite_movies : has
favorite_movies }|--o{ movies : containsmovies }|--|| persons : director
movies }|--|| countries : production
movies }|--o| files : poster
movies }|--|{ movie_characters : has
movie_characters }|--|{ characters : contains
movies }|--|{ movie_genres : has
movie_genres }|--|{ genres : containspersons }|--|| countries : home
persons }|--o| files : photo
persons }o--|{ person_images: has
person_images }|--o{ files : containscharacters }o--|{ character_actors : has
character_actors }|--|{ persons : contains
``````mermaid
---
title: Detailed Entity Relationship Diagram
---
erDiagram
users }o--|{ favorite_movies : has
favorite_movies }|--o{ movies : containsmovies }|--|| persons : director
movies }|--|| countries : production
movies }|--o| files : poster
movies }|--|{ movie_characters : has
movie_characters }|--|{ characters : contains
movies }|--|{ movie_genres : has
movie_genres }|--|{ genres : containspersons }|--|| countries : home
persons }|--o| files : photo
persons }o--|{ person_images: has
person_images }|--o{ files : containscharacters }o--|{ character_actors : has
character_actors }|--|{ persons : containsusers {
VARCHAR(50) id PK
VARCHAR(50) username UK "NOT NULL"
TEXT first_name "NOT NULL"
TEXT last_name "NOT NULL"
TEXT email UK "NOT NULL"
TEXT password "NOT NULL"
}
favorite_movies {
VARCHAR(50) id PK
VARCHAR(50) user_id FK "users ON DELETE CASCADE"
VARCHAR(50) movie_id FK "movies ON DELETE CASCADE"
}files {
VARCHAR(50) id PK
TEXT file_name "NOT NULL"
TEXT mime_type "NOT NULL"
TEXT source_url "NOT NULL"
}movies {
VARCHAR(50) id PK
TEXT title "NOT NULL"
TEXT description
INTEGER budget
DATE release_date
INTEGER duration
VARCHAR(50) director FK "persons ON DELETE RESTRICT, NOT NULL"
VARCHAR(50) production FK "countries ON DELETE RESTRICT, NOT NULL"
VARCHAR(50) poster FK "files ON DELETE SET NULL"
}
movie_characters {
VARCHAR(50) id PK
VARCHAR(50) movie_id FK "movies ON DELETE CASCADE, NOT NULL"
VARCHAR(50) character_id FK,UK "characters ON DELETE CASCADE, NOT NULL"
}
movie_genres {
VARCHAR(50) id PK
VARCHAR(50) movie_id FK "movies ON DELETE CASCADE, NOT NULL"
VARCHAR(50) genre_id FK,UK "genres ON DELETE CASCADE, NOT NULL"
}enum_cr[CHARACTER_ROLE_enum] {
_ leading
_ supporting
_ background
}
characters {
VARCHAR(50) id PK
TEXT name "NOT NULL"
TEXT description
CHARACTER_ROLE_enum role "NOT NULL"
}
characters }|..|| enum_cr : has
character_actors {
VARCHAR(50) id PK
VARCHAR(50) character_id FK "characters ON DELETE CASCADE, NOT NULL"
VARCHAR(50) person_id FK "persons ON DELETE CASCADE, NOT NULL"
}enum_g[GENDER_enum] {
_ male
_ female
_ other
}
persons {
VARCHAR(50) id PK
TEXT first_name "NOT NULL"
TEXT last_name "NOT NULL"
TEXT biography
DATE birth_date
GENDER_enum gender "NOT NULL"
VARCHAR(50) nationality FK "countries ON DELETE RESTRICT, NOT NULL"
VARCHAR(50) photo FK "files ON DELETE SET NULL"
}
persons }|..|| enum_g : has
person_images {
VARCHAR(50) id PK
VARCHAR(50) person_id FK "persons ON DELETE CASCADE, NOT NULL"
VARCHAR(50) file_id FK "files ON DELETE CASCADE, NOT NULL"
}countries {
VARCHAR(50) id PK
VARCHAR(3) iso_3166_1 UK "NOT NULL"
TEXT name "NOT NULL"
}genres {
VARCHAR(50) id PK
TEXT name "NOT NULL"
}
```