Skip to main content

Overview

Sistema Magdaleno uses a MySQL database (venezuela_naciones) with a comprehensive schema supporting content management, user authentication, ACL permissions, and business operations. The database follows CakePHP naming conventions with snake_case table and column names.

Core Tables

Users & Authentication

users

Stores user account information and credentials.
ColumnTypeDescription
id_usuarioINT(11)Primary key (auto-increment)
usernameVARCHAR(45)Unique username for login
email_usuarioVARCHAR(45)User email address
passwordVARCHAR(45)Hashed password (SHA1)
perfil_usuarioVARCHAR(255)User’s full name/profile
fecharreg_usuarioTIMESTAMPRegistration timestamp
groups_idgruposINT(11)Foreign key to groups table
Relationships:
  • belongsTo Group (via groups_idgrupos)
  • Integrates with Aro for ACL

groups

Defines user permission groups.
ColumnTypeDescription
idgruposINT(11)Primary key (auto-increment)
name_gruposVARCHAR(45)Group identifier (e.g., “administradores”)
titulo_gruposVARCHAR(45)Group display title
fechacrea_grupoTIMESTAMPCreation timestamp
Relationships:
  • hasMany Users
  • Integrates with Aro for ACL

Access Control Lists (ACL)

acos (Access Control Objects)

Defines the tree structure of controllable resources.
ColumnTypeDescription
idINT(10) UNSIGNEDPrimary key (auto-increment)
parent_idINT(10)Parent ACO node for tree structure
modelVARCHAR(255)Associated model name
foreign_keyINT(10) UNSIGNEDForeign key to model
aliasVARCHAR(255)Resource identifier (controller/action)
lftINT(10)Left value for nested set
rghtINT(10)Right value for nested set
Structure:
  • Root node: controllers (id=1)
  • Child nodes: Controller names (Pages, Users, Galleries, etc.)
  • Leaf nodes: Action names (index, add, edit, delete, view)

aros (Access Request Objects)

Defines the tree structure of permission requesters (users/groups).
ColumnTypeDescription
idINT(10) UNSIGNEDPrimary key (auto-increment)
parent_idINT(10)Parent ARO node for tree structure
modelVARCHAR(255)Model name (Group or User)
foreign_keyINT(10) UNSIGNEDForeign key to Group or User
aliasVARCHAR(255)Requester alias
lftINT(10)Left value for nested set
rghtINT(10)Right value for nested set
Structure:
  • Groups at top level
  • Users nested under their respective groups

aros_acos

Junction table linking AROs to ACOs with CRUD permissions.
ColumnTypeDescription
idINT(10) UNSIGNEDPrimary key (auto-increment)
aro_idINT(10) UNSIGNEDForeign key to aros
aco_idINT(10) UNSIGNEDForeign key to acos
_createCHAR(2)Create permission (0, 1, -1)
_readCHAR(2)Read permission (0, 1, -1)
_updateCHAR(2)Update permission (0, 1, -1)
_deleteCHAR(2)Delete permission (0, 1, -1)
Permission Values:
  • 1 = Allow
  • 0 = Deny
  • -1 = Inherit from parent

Content Management

galleries

Stores image gallery information.
ColumnTypeDescription
id_galeriaINT(11)Primary key (auto-increment)
texto_galeriaVARCHAR(255)Gallery title
publicarINT(11)Publication status (0/1)
descripcionTEXTGallery description
thumbnailsTEXTThumbnail image filename
urlVARCHAR(255)SEO-friendly URL slug
fechacre_galeriaTIMESTAMPCreation timestamp
usuario_id_usuarioINT(11)Foreign key to users
excluirTINYINT(4)Exclusion flag (default: 0)
clavesVARCHAR(255)Keywords/tags
Relationships:
  • belongsTo User
  • hasAndBelongsToMany Archivo (via archivos_galleries)

archivos (files)

Stores uploaded file metadata.
ColumnTypeDescription
id_fileINT(11)Primary key (auto-increment)
nombre_fileVARCHAR(45)Original filename
vidthumbnailVARCHAR(255)Video thumbnail
embedthumbVARCHAR(255)Embedded thumbnail
viddestaVARCHAR(255)Featured video indicator
nombre_galVARCHAR(255)Gallery name
nombre_thumbVARCHAR(255)Thumbnail name
dirVARCHAR(255)Directory path
fechacre_fileTIMESTAMPUpload timestamp
mimetypeVARCHAR(45)MIME type
tipodispositivo_fileVARCHAR(45)Device type
usuario_id_usuarioINT(11)Foreign key to users

archivos_galleries

Junction table linking files to galleries.
ColumnTypeDescription
files_id_fileINT(11)Foreign key to archivos (primary)
galerias_id_galeriaINT(11)Foreign key to galleries (primary)

videos

Stores video content and metadata.
ColumnTypeDescription
id_videosINT(11)Primary key (auto-increment)
videoembedLONGTEXTEmbedded video HTML/code
titulo_videoVARCHAR(255)Video title
descripcionTEXTVideo description
etiquetaVARCHAR(255)Tags/labels
destacadoVARCHAR(255)Featured status
urlVARCHAR(255)SEO-friendly URL slug
fechacre_videosTIMESTAMPCreation timestamp
usuario_id_usuarioINT(11)Foreign key to users
archivos_id_fileINT(11)Foreign key to archivos (thumbnail)
excluirTINYINT(4)Exclusion flag (default: 0)
video_homeTINYINT(1)Show on homepage (default: 0)

categories

Hierarchical category structure.
ColumnTypeDescription
id_categoriasINT(11)Primary key (auto-increment)
parent_idINT(11)Parent category for hierarchy
nombre_categoriasVARCHAR(45)Category name
link_categoriasVARCHAR(45)URL slug
estilo_categoriasVARCHAR(45)Style/theme
fechacre_categoriasTIMESTAMPCreation timestamp
status_categoriasINT(11)Status indicator
usuario_id_usuarioINT(11)Foreign key to users
categorias_id_categoriasINT(11)Self-referential foreign key

Business/Campaign Management

registers

User registration and campaign participation.
ColumnTypeDescription
idregistroINT(11)Primary key (auto-increment)
nombreapeVARCHAR(45)Full name
sexoCHAR(1)Gender (M/F)
fechanacDATEBirth date
direccionVARCHAR(45)Address
paisVARCHAR(45)Country
correoVARCHAR(45)Email
telefonoBIGINT(20)Phone number
passwordVARCHAR(45)Password
rpassVARCHAR(255)Repeated password
estadoVARCHAR(45)State/province
ciudadVARCHAR(255)City
codigoINT(11)Code/verification
teconINT(255)Terms accepted flag
scorINT(11)Score
cuentatwitterVARCHAR(255)Twitter handle
fbookidVARCHAR(255)Facebook ID
fblinkperfilVARCHAR(255)Facebook profile link
fotoVARCHAR(45)Photo filename
pais_campanaVARCHAR(255)Campaign country

campanas

Marketing campaigns.
ColumnTypeDescription
id_campanaINT(11)Primary key (auto-increment)
pais_campanaVARCHAR(255)Target country
descripcionTEXTCampaign description
montoDOUBLEBudget amount
fechaVARCHAR(25)Campaign date
activoINT(11)Active status (0/1)
idpaisINT(11)Foreign key to paises

Geographic Data

paises (countries)

Country reference data.
ColumnTypeDescription
paisIdINT(11)Primary key (auto-increment)
isoNumSMALLINT(6)ISO numeric code
iso2CHAR(2)ISO 2-letter code
iso3CHAR(3)ISO 3-letter code
nombreVARCHAR(80)Country name (Spanish)
codtelINT(11)Phone country code
prioridadINT(11)Display priority

estados (states)

Venezuelan states.
ColumnTypeDescription
estadoIdINT(8)Primary key
nombreVARCHAR(50)State name
ordINT(8)Display order

ciudades (cities)

Venezuelan cities.
ColumnTypeDescription
ciudadIdINT(8)Primary key (auto-increment)
nombreVARCHAR(100)City name
estadoIdINT(8)Foreign key to estados
ordINT(8)Display order

Entity Relationship Diagram

┌─────────────┐
│   groups    │
│             │
│ idgrupos PK │◄──────┐
└─────────────┘       │
       │              │
       │ hasMany      │ belongsTo
       │              │
       ▼              │
┌─────────────────────┴───┐       ┌──────────────┐
│       users             │       │    aros      │
│                         │       │              │
│ id_usuario PK           │◄──────┤ foreign_key  │
│ groups_idgrupos FK      │       │ model='User' │
│ username                │       └──────────────┘
│ email_usuario           │              │
│ password                │              │ HABTM
└─────────────────────────┘              │
       │                                 ▼
       │ hasMany              ┌─────────────────┐
       │                      │   aros_acos     │
       │                      │                 │
       ▼                      │ aro_id FK       │
┌─────────────────┐           │ aco_id FK       │
│   galleries     │           │ _create         │
│                 │           │ _read           │
│ id_galeria PK   │           │ _update         │
│ usuario_id FK   │           │ _delete         │
└─────────────────┘           └─────────────────┘
       │                                 ▲
       │ HABTM                            │ HABTM
       │                                 │
       ▼                      ┌──────────────────┐
┌──────────────────┐          │      acos        │
│archivos_galleries│          │                  │
│                  │          │ id PK            │
│ files_id_file FK │          │ parent_id        │
│ galerias_id FK   │          │ alias            │
└──────────────────┘          │ (controllers/    │
       │                      │  actions)        │
       │                      └──────────────────┘

┌─────────────────┐
│    archivos     │
│                 │
│ id_file PK      │
│ nombre_file     │
│ dir             │
│ mimetype        │
└─────────────────┘

Database Conventions

Naming Patterns

  1. Table Names: Lowercase, plural, snake_case (e.g., archivos_galleries)
  2. Primary Keys: id or {singular}_id (e.g., id_usuario, id_galeria)
  3. Foreign Keys: {table_singular}_id{column} (e.g., usuario_id_usuario, groups_idgrupos)
  4. Timestamps: fecha{action}_{table} (e.g., fechacre_galeria, fecharreg_usuario)
  5. Junction Tables: {table1}_{table2} alphabetically ordered

Character Set & Engine

  • Default Character Set: UTF-8 (utf8) / Latin1 for some tables
  • Collation: latin1_swedish_ci / utf8_general_ci
  • Storage Engine: InnoDB for transactional tables, MyISAM for ACL tables

Key Indexes

Performance Indexes

-- Galleries URL lookup
INDEX `url` ON galleries(url);

-- User authentication
INDEX `fk_users_groups1` ON users(groups_idgrupos);

-- File-Gallery relationships
PRIMARY KEY ON archivos_galleries(files_id_file, galerias_id_galeria);

Database Initialization

The database is created with:
CREATE DATABASE `venezuela_naciones` 
  DEFAULT CHARACTER SET latin1 
  COLLATE latin1_swedish_ci;
All tables use AUTO_INCREMENT for primary keys and CURRENT_TIMESTAMP for creation timestamps where applicable.

Build docs developers (and LLMs) love