How nemryz/dbii works
Purpose and Runtime
This is a PostgreSQL course-lab repository, not an application service. It builds and exercises a logistics database (logitrack) using PostgreSQL 15–17, executed through psql or pgAdmin4. The primary operational entry point is the ordered SQL load described by README.md.
Bootstrap Pipeline
1. Create a target database (lab_db) externally with PostgreSQL tooling.
2. Create the relational schema and integrity constraints via Laboratorios_Code/Lab01/modeloDiagrama.sql.
3. Load/reset example data and synchronize serial sequences via Laboratorios_Code/Lab01/poblacion.sql.
4. Run Lab02 scripts in numerical order against the populated schema.
The schema/data boundary is explicit: DDL belongs to the model script; repeatable reset and seed DML belong to the population script.
Core Domain Model
Lab01 defines the canonical logitrack logistics data model: thirteen tables, including relationship-heavy inventory/order structures. Laboratorios_Code/Lab01/modeloDiagrama.sql is the authoritative schema implementation; Laboratorios_Code/Lab01/modeloBorrador.sql is an earlier, non-authoritative model version. Referential integrity and primary-key behavior are enforced in PostgreSQL rather than application code.
Dataset and Sequence Consistency
Laboratorios_Code/Lab01/poblacion.sql clears and repopulates the schema with representative records, including larger many-to-many/detail datasets for suppliers/products and order details. It calls setval after explicit-ID inserts so subsequent inserts use non-conflicting generated keys. This makes the seed state a prerequisite for mutation exercises and transaction scripts.
Query and Database-Operation Exercises
Lab02 is the consumer layer over the Lab01 database. The definitive modular scripts are under Laboratorios_Code/Lab02/ConsultasL02/consultas/, including:
• DDL/auditing: 04_ddl_auditoria_inventario.sql
• Baseline DML: 05_dml_basicas.sql
• relational reporting: 06_consultas_join.sql
• transaction semantics: 12_transaccion_commit.sql, 13_transaccion_rollback.sql, 14_transaccion_savepoint.sql
Scripts establish SET search_path TO logitrack, isolating consumers from the session’s default schema configuration. They are intended to work in both psql and pgAdmin4, avoiding incompatible psql meta-commands where possible.
Execution Variants and Recovery Boundary
Consolidated, cross-client variants live in Laboratorios_Code/Lab02/ConsultasL02/consultas.sql, parte_6.sql, and tarea4_ddl.sql; pgAdmin-oriented copies are in Laboratorios_Code/Lab02/ConsultasL02/Consultas pgadmin/. These are alternate execution representations, not separate services.
Database portability/recovery is handled with PostgreSQL-native tooling: Laboratorios_Code/Lab02/ConsultasL02/DBIILab02_10_backup.sql is a full dump, while restore/backup procedures are documented in Laboratorios_Code/Lab02/ConsultasL02/terminal/10_backup_pg_dump.md and 11_restaurar_backup.md.
Main entry points: modeloDiagrama.sql logitrack schema · poblacion.sql Reset and seed data · DBIILab02_10_backup.sql Full database dump · 05_dml_basicas.sql Basic DML
Components 16
Lab01 bootstrap
Builds the canonical database and repeatable seed state.
- lab_db · Externally created database containing the logitrack schema.
- logitrack schema · Thirteen-table logistics model with database-enforced keys and references.
Laboratorios_Code/Lab01/modeloDiagrama.sql - Reset and seed data · Repopulates records and synchronizes serial sequences after explicit IDs.
Laboratorios_Code/Lab01/poblacion.sql - Earlier model draft · Superseded model version.
Laboratorios_Code/Lab01/modeloBorrador.sql
Lab02 exercises
Ordered consumer scripts run against the populated schema.
- Inventory audit DDL
Laboratorios_Code/Lab02/ConsultasL02/consultas/04_ddl_auditoria_inventario.sql - Basic DML
Laboratorios_Code/Lab02/ConsultasL02/consultas/05_dml_basicas.sql - Join reports
Laboratorios_Code/Lab02/ConsultasL02/consultas/06_consultas_join.sql - Commit transaction
Laboratorios_Code/Lab02/ConsultasL02/consultas/12_transaccion_commit.sql - Rollback transaction
Laboratorios_Code/Lab02/ConsultasL02/consultas/13_transaccion_rollback.sql - Savepoint transaction
Laboratorios_Code/Lab02/ConsultasL02/consultas/14_transaccion_savepoint.sql - Consolidated variants · Alternate combined execution representations, not separate services.
Laboratorios_Code/Lab02/ConsultasL02/consultas.sql - pgAdmin variants
Backup and recovery
PostgreSQL-native portability and recovery materials.
- Full database dump
Laboratorios_Code/Lab02/ConsultasL02/DBIILab02_10_backup.sql - Backup procedure
Laboratorios_Code/Lab02/ConsultasL02/terminal/10_backup_pg_dump.md - Restore procedure
Laboratorios_Code/Lab02/ConsultasL02/terminal/11_restaurar_backup.md
Other components
- PostgreSQL 15–17 · Target runtime operated through psql or pgAdmin4.
Connections 18
- PostgreSQL 15–17 → lab_db: hosts
- logitrack schema → lab_db: creates logitrack
- Reset and seed data → logitrack schema: resets and populates
- Basic DML → Reset and seed data: requires seed state
- Inventory audit DDL → logitrack schema: extends
- Basic DML → logitrack schema: mutates
- Join reports → logitrack schema: queries
- Commit transaction → Reset and seed data: requires seed state
- Rollback transaction → Reset and seed data: requires seed state
- Savepoint transaction → Reset and seed data: requires seed state
- Commit transaction → logitrack schema: tests transaction semantics
- Rollback transaction → logitrack schema: tests transaction semantics
- Savepoint transaction → logitrack schema: tests transaction semantics
- Consolidated variants → Inventory audit DDL: alternate representation
- pgAdmin variants → Consolidated variants: client-oriented variants
- Full database dump → lab_db: captures
- Backup procedure → Full database dump: documents creation
- Restore procedure → Full database dump: documents restoration