# tomasocchi/lab-bd architecture

> Architecture diagram of the GitHub repository tomasocchi/lab-bd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tomasocchi/lab-bd
- Repository: https://github.com/tomasocchi/lab-bd

## Overview

#### Purpose and Scope
This repository is a SQL coursework/database exercise set targeting both MySQL and PostgreSQL. It defines, populates, queries, updates, and cleans relational databases across two staged deliverables: initial schema/data work (`tp1`) and subsequent data manipulation plus views (`tp2`).

#### Database Platform Boundary
MySQL and PostgreSQL are supported through parallel dialect-specific scripts rather than a shared migration runtime. PostgreSQL additionally separates domain/type setup from schema creation:
- `tp1/creacionalMySQL.sql`
- `tp1/creacionalPostgreSQL.sql`
- `tp1/dominiosPostgreSQL.sql`

Consumers must execute the scripts using their respective database client or deployment mechanism; no application runtime or orchestration layer is present.

#### TP1: Schema Initialization
The initial structural stage creates the database objects required by the exercises. PostgreSQL setup likely requires domains before table creation, while MySQL uses its own creation script:
- `tp1/dominiosPostgreSQL.sql`
- `tp1/creacionalPostgreSQL.sql`
- `tp1/creacionalMySQL.sql`

This is the primary schema boundary: later scripts assume these database objects already exist.

#### TP1: Seed Data by Schema/Scenario
Initial data is divided into two population sets, apparently representing separate schemas or exercise datasets. Each DBMS has equivalent seed scripts:
- `tp1/pobladoBD1MySQL.sql`
- `tp1/pobladoBD2MySQL.sql`
- `tp1/pobladoEsquema1PostgreSQL.sql`
- `tp1/pobladoEsquema2PostgreSQL.sql`

The selected seed path determines the dataset available to downstream exercise queries and mutations.

#### TP1: Query Exercises and Reset
Standalone exercise scripts execute database queries against the initialized/populated state. MySQL and PostgreSQL receive separate implementations for exercise 6, while exercise 7 is shared:
- `tp1/ej6mysql.sql`
- `tp1/ej6pg.sql`
- `tp1/ej7.sql`

Cleanup scripts return each platform’s database to a cleared state, making them the lifecycle termination/reset boundary:
- `tp1/limpiezaMySQL.sql`
- `tp1/limpiezaPostgreSQL.sql`

#### TP2: Mutations and Derived Views
The second stage operates on an existing schema and dataset. It contains insertion and update scripts in both SQL dialects, followed by database views that expose derived/queryable representations:
- `tp2/insercionesMySQL.sql`
- `tp2/actualizacionesMySQL.sql`
- `tp2/vistasMySQL.sql`
- `tp2/insercionesPostgreSQL.sql`
- `tp2/actualizacionesPostgreSQL.sql`
- `tp2/vistasPostgreSQL.sql`

The intended control flow is schema creation → population → TP2 insertions/updates → view creation/use.

#### Assertions
`tp2/afirmaciones.SQL` appears to hold declarative statements or validation assertions over the resulting database state:
- `tp2/afirmaciones.SQL`

It functions as a verification boundary after data changes and view definitions, though its DBMS compatibility cannot be determined from the file tree alone.

Main entry points: [`tp1/pobladoBD1MySQL.sql`](https://github.com/tomasocchi/lab-bd/blob/main/tp1/pobladoBD1MySQL.sql) (Seed dataset 1), [`tp1/pobladoBD2MySQL.sql`](https://github.com/tomasocchi/lab-bd/blob/main/tp1/pobladoBD2MySQL.sql) (Seed dataset 2), [`tp1/creacionalPostgreSQL.sql`](https://github.com/tomasocchi/lab-bd/blob/main/tp1/creacionalPostgreSQL.sql) (TP1 schema creation), [`tp1/pobladoEsquema1PostgreSQL.sql`](https://github.com/tomasocchi/lab-bd/blob/main/tp1/pobladoEsquema1PostgreSQL.sql) (Seed schema 1)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mysql["MySQL"]
  node_mysql_schema["TP1 schema creation<br/>MySQL DDL"]
  node_mysql_seed_bd1["Seed dataset 1<br/>MySQL seed"]
  node_mysql_seed_bd2["Seed dataset 2<br/>MySQL seed"]
  node_mysql_ex6["Exercise 6 queries<br/>MySQL query<br/>[ej6mysql.sql]"]
  node_mysql_cleanup["Database cleanup<br/>MySQL reset<br/>[limpiezaMySQL.sql]"]
  node_mysql_insert["TP2 insertions<br/>MySQL mutation"]
  node_mysql_update["TP2 updates<br/>MySQL mutation"]
  node_mysql_views["TP2 views<br/>MySQL views<br/>[vistasMySQL.sql]"]
  node_mysql_db[("MySQL exercise database<br/>database state")]
end

subgraph group_postgresql["PostgreSQL"]
  node_pg_domains["Domain/type setup<br/>PostgreSQL DDL"]
  node_pg_schema["TP1 schema creation<br/>PostgreSQL DDL"]
  node_pg_seed_schema1["Seed schema 1<br/>PostgreSQL seed"]
  node_pg_seed_schema2["Seed schema 2<br/>PostgreSQL seed"]
  node_pg_ex6["Exercise 6 queries<br/>PostgreSQL query<br/>[ej6pg.sql]"]
  node_pg_cleanup["Database cleanup<br/>PostgreSQL reset"]
  node_pg_insert["TP2 insertions<br/>PostgreSQL mutation"]
  node_pg_update["TP2 updates<br/>PostgreSQL mutation"]
  node_pg_views["TP2 views<br/>PostgreSQL views"]
  node_pg_db[("PostgreSQL exercise database<br/>database state")]
end

subgraph group_shared["Shared exercises"]
  node_ex7["Exercise 7 queries<br/>shared query<br/>[ej7.sql]"]
  node_assertions["Result assertions<br/>verification SQL<br/>[afirmaciones.SQL]"]
end

node_mysql_schema -->|"creates"| node_mysql_db
node_mysql_schema -->|"enables"| node_mysql_seed_bd1
node_mysql_schema -->|"enables"| node_mysql_seed_bd2
node_mysql_seed_bd1 -->|"populates"| node_mysql_db
node_mysql_seed_bd2 -->|"populates"| node_mysql_db
node_mysql_seed_bd1 -.->|"query input"| node_mysql_ex6
node_mysql_seed_bd2 -.->|"query input"| node_mysql_ex6
node_mysql_seed_bd1 -->|"TP2 starting state"| node_mysql_insert
node_mysql_seed_bd2 -->|"TP2 starting state"| node_mysql_insert
node_mysql_insert -->|"then"| node_mysql_update
node_mysql_update -->|"then"| node_mysql_views
node_mysql_views -.->|"verify"| node_assertions
node_mysql_db -->|"reset"| node_mysql_cleanup
node_pg_domains -->|"defines prerequisites"| node_pg_schema
node_pg_schema -->|"creates"| node_pg_db
node_pg_schema -->|"enables"| node_pg_seed_schema1
node_pg_schema -->|"enables"| node_pg_seed_schema2
node_pg_seed_schema1 -->|"populates"| node_pg_db
node_pg_seed_schema2 -->|"populates"| node_pg_db
node_pg_seed_schema1 -.->|"query input"| node_pg_ex6
node_pg_seed_schema2 -.->|"query input"| node_pg_ex6
node_pg_seed_schema1 -->|"TP2 starting state"| node_pg_insert
node_pg_seed_schema2 -->|"TP2 starting state"| node_pg_insert
node_pg_insert -->|"then"| node_pg_update
node_pg_update -->|"then"| node_pg_views
node_pg_views -.->|"verify"| node_assertions
node_pg_db -->|"reset"| node_pg_cleanup
node_mysql_db -.->|"runs against"| node_ex7
node_pg_db -.->|"runs against"| node_ex7

click node_mysql_schema "https://github.com/tomasocchi/lab-bd/blob/main/tp1/creacionalMySQL.sql"
click node_mysql_seed_bd1 "https://github.com/tomasocchi/lab-bd/blob/main/tp1/pobladoBD1MySQL.sql"
click node_mysql_seed_bd2 "https://github.com/tomasocchi/lab-bd/blob/main/tp1/pobladoBD2MySQL.sql"
click node_mysql_ex6 "https://github.com/tomasocchi/lab-bd/blob/main/tp1/ej6mysql.sql"
click node_mysql_cleanup "https://github.com/tomasocchi/lab-bd/blob/main/tp1/limpiezaMySQL.sql"
click node_mysql_insert "https://github.com/tomasocchi/lab-bd/blob/main/tp2/insercionesMySQL.sql"
click node_mysql_update "https://github.com/tomasocchi/lab-bd/blob/main/tp2/actualizacionesMySQL.sql"
click node_mysql_views "https://github.com/tomasocchi/lab-bd/blob/main/tp2/vistasMySQL.sql"
click node_pg_domains "https://github.com/tomasocchi/lab-bd/blob/main/tp1/dominiosPostgreSQL.sql"
click node_pg_schema "https://github.com/tomasocchi/lab-bd/blob/main/tp1/creacionalPostgreSQL.sql"
click node_pg_seed_schema1 "https://github.com/tomasocchi/lab-bd/blob/main/tp1/pobladoEsquema1PostgreSQL.sql"
click node_pg_seed_schema2 "https://github.com/tomasocchi/lab-bd/blob/main/tp1/pobladoEsquema2PostgreSQL.sql"
click node_pg_ex6 "https://github.com/tomasocchi/lab-bd/blob/main/tp1/ej6pg.sql"
click node_pg_cleanup "https://github.com/tomasocchi/lab-bd/blob/main/tp1/limpiezaPostgreSQL.sql"
click node_pg_insert "https://github.com/tomasocchi/lab-bd/blob/main/tp2/insercionesPostgreSQL.sql"
click node_pg_update "https://github.com/tomasocchi/lab-bd/blob/main/tp2/actualizacionesPostgreSQL.sql"
click node_pg_views "https://github.com/tomasocchi/lab-bd/blob/main/tp2/vistasPostgreSQL.sql"
click node_ex7 "https://github.com/tomasocchi/lab-bd/blob/main/tp1/ej7.sql"
click node_assertions "https://github.com/tomasocchi/lab-bd/blob/main/tp2/afirmaciones.SQL"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mysql_schema,node_mysql_seed_bd1,node_mysql_seed_bd2,node_mysql_ex6,node_mysql_cleanup,node_mysql_insert,node_mysql_update,node_mysql_views,node_mysql_db toneBlue
class node_pg_domains,node_pg_schema,node_pg_seed_schema1,node_pg_seed_schema2,node_pg_ex6,node_pg_cleanup,node_pg_insert,node_pg_update,node_pg_views,node_pg_db toneAmber
class node_ex7,node_assertions toneMint
```

## Components

### MySQL

Dialect-specific SQL lifecycle.

- [TP1 schema creation](https://github.com/tomasocchi/lab-bd/blob/main/tp1/creacionalMySQL.sql): MySQL DDL · `tp1/creacionalMySQL.sql`
- [Seed dataset 1](https://github.com/tomasocchi/lab-bd/blob/main/tp1/pobladoBD1MySQL.sql): MySQL seed · `tp1/pobladoBD1MySQL.sql`
- [Seed dataset 2](https://github.com/tomasocchi/lab-bd/blob/main/tp1/pobladoBD2MySQL.sql): MySQL seed · `tp1/pobladoBD2MySQL.sql`
- [Exercise 6 queries](https://github.com/tomasocchi/lab-bd/blob/main/tp1/ej6mysql.sql): MySQL query · `tp1/ej6mysql.sql`
- [Database cleanup](https://github.com/tomasocchi/lab-bd/blob/main/tp1/limpiezaMySQL.sql): MySQL reset · Clears the MySQL exercise state. · `tp1/limpiezaMySQL.sql`
- [TP2 insertions](https://github.com/tomasocchi/lab-bd/blob/main/tp2/insercionesMySQL.sql): MySQL mutation · `tp2/insercionesMySQL.sql`
- [TP2 updates](https://github.com/tomasocchi/lab-bd/blob/main/tp2/actualizacionesMySQL.sql): MySQL mutation · `tp2/actualizacionesMySQL.sql`
- [TP2 views](https://github.com/tomasocchi/lab-bd/blob/main/tp2/vistasMySQL.sql): MySQL views · `tp2/vistasMySQL.sql`
- **MySQL exercise database**: database state · Created, populated, queried, and reset by MySQL scripts.

### PostgreSQL

Dialect-specific SQL lifecycle.

- [Domain/type setup](https://github.com/tomasocchi/lab-bd/blob/main/tp1/dominiosPostgreSQL.sql): PostgreSQL DDL · Must precede PostgreSQL schema creation. · `tp1/dominiosPostgreSQL.sql`
- [TP1 schema creation](https://github.com/tomasocchi/lab-bd/blob/main/tp1/creacionalPostgreSQL.sql): PostgreSQL DDL · `tp1/creacionalPostgreSQL.sql`
- [Seed schema 1](https://github.com/tomasocchi/lab-bd/blob/main/tp1/pobladoEsquema1PostgreSQL.sql): PostgreSQL seed · `tp1/pobladoEsquema1PostgreSQL.sql`
- [Seed schema 2](https://github.com/tomasocchi/lab-bd/blob/main/tp1/pobladoEsquema2PostgreSQL.sql): PostgreSQL seed · `tp1/pobladoEsquema2PostgreSQL.sql`
- [Exercise 6 queries](https://github.com/tomasocchi/lab-bd/blob/main/tp1/ej6pg.sql): PostgreSQL query · `tp1/ej6pg.sql`
- [Database cleanup](https://github.com/tomasocchi/lab-bd/blob/main/tp1/limpiezaPostgreSQL.sql): PostgreSQL reset · Clears the PostgreSQL exercise state. · `tp1/limpiezaPostgreSQL.sql`
- [TP2 insertions](https://github.com/tomasocchi/lab-bd/blob/main/tp2/insercionesPostgreSQL.sql): PostgreSQL mutation · `tp2/insercionesPostgreSQL.sql`
- [TP2 updates](https://github.com/tomasocchi/lab-bd/blob/main/tp2/actualizacionesPostgreSQL.sql): PostgreSQL mutation · `tp2/actualizacionesPostgreSQL.sql`
- [TP2 views](https://github.com/tomasocchi/lab-bd/blob/main/tp2/vistasPostgreSQL.sql): PostgreSQL views · `tp2/vistasPostgreSQL.sql`
- **PostgreSQL exercise database**: database state · Created, populated, queried, and reset by PostgreSQL scripts.

### Shared exercises

Scripts not split by database platform.

- [Exercise 7 queries](https://github.com/tomasocchi/lab-bd/blob/main/tp1/ej7.sql): shared query · `tp1/ej7.sql`
- [Result assertions](https://github.com/tomasocchi/lab-bd/blob/main/tp2/afirmaciones.SQL): verification SQL · Validates state after TP2 changes and views. · `tp2/afirmaciones.SQL`

## Connections

- TP1 schema creation → MySQL exercise database: creates
- TP1 schema creation → Seed dataset 1: enables
- TP1 schema creation → Seed dataset 2: enables
- Seed dataset 1 → MySQL exercise database: populates
- Seed dataset 2 → MySQL exercise database: populates
- Seed dataset 1 → Exercise 6 queries: query input
- Seed dataset 2 → Exercise 6 queries: query input
- Seed dataset 1 → TP2 insertions: TP2 starting state
- Seed dataset 2 → TP2 insertions: TP2 starting state
- TP2 insertions → TP2 updates: then
- TP2 updates → TP2 views: then
- TP2 views → Result assertions: verify
- MySQL exercise database → Database cleanup: reset
- Domain/type setup → TP1 schema creation: defines prerequisites
- TP1 schema creation → PostgreSQL exercise database: creates
- TP1 schema creation → Seed schema 1: enables
- TP1 schema creation → Seed schema 2: enables
- Seed schema 1 → PostgreSQL exercise database: populates
- Seed schema 2 → PostgreSQL exercise database: populates
- Seed schema 1 → Exercise 6 queries: query input
- Seed schema 2 → Exercise 6 queries: query input
- Seed schema 1 → TP2 insertions: TP2 starting state
- Seed schema 2 → TP2 insertions: TP2 starting state
- TP2 insertions → TP2 updates: then
- TP2 updates → TP2 views: then
- TP2 views → Result assertions: verify
- PostgreSQL exercise database → Database cleanup: reset
- MySQL exercise database → Exercise 7 queries: runs against
- PostgreSQL exercise database → Exercise 7 queries: runs against
