Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/wreyesus/Sencillo_Carrito_de_Compras_en_PHP/llms.txt

Use this file to discover all available pages before exploring further.

The YUME|TEC store uses a single MySQL database named tienda composed of four tables: categorias, productos, usuario, and compra. The schema was originally created with phpMyAdmin 2.11.4 running MySQL 5.1.57 and PHP 5.2.17. The dump file lives at BD/bd.sql and can be imported directly into any compatible MySQL server to recreate the full structure along with the 31 seed products.

categorias table

Holds the product categories displayed in the storefront navigation. The contiene column is informational and records how many products belong to each category, but this value is not automatically updated — it is not enforced by a database trigger or foreign key.
CREATE TABLE categorias (
  id_cat    INT(6)      NOT NULL AUTO_INCREMENT,
  nombre    VARCHAR(40) NOT NULL,
  contiene  INT(6)      NOT NULL,
  PRIMARY KEY (id_cat)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
ColumnTypeDescription
id_catINT(6) AUTO_INCREMENT PKUnique category identifier. Referenced by productos.id_cat.
nombreVARCHAR(40)Human-readable category name (e.g. procesadores, motherboards, rams).
contieneINT(6)Informational product count. Not enforced by any foreign key or trigger.
Seed data — 3 rows:
id_catnombrecontiene
1procesadores10
2motherboards10
3rams10

productos table

The main product catalogue. Each row represents one SKU, linked to a category via id_cat. Images are stored as bare filenames (e.g. acc393.jpg) that must be resolved against the imagenes/ directory at runtime.
CREATE TABLE productos (
  id_producto  INT(6)                                        NOT NULL AUTO_INCREMENT,
  id_cat       INT(6)                                        NOT NULL,
  nombre       VARCHAR(40)                                   NOT NULL,
  fabricante   VARCHAR(32)                                   NOT NULL,
  precio       DECIMAL(5,2)                                  NOT NULL,
  imagen       VARCHAR(30)                                   NOT NULL,
  descripcion  TEXT CHARACTER SET utf8 COLLATE utf8_spanish2_ci NOT NULL,
  PRIMARY KEY (id_producto),
  KEY categoria (id_cat)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
ColumnTypeDescription
id_productoINT(6) AUTO_INCREMENT PKUnique product identifier.
id_catINT(6)Category reference. No enforced foreign key constraint — the relationship is maintained by application logic only.
nombreVARCHAR(40)Product name as displayed in the store and stored in the cart session (e.g. Core i3 2100 3.01Ghz).
fabricanteVARCHAR(32)Manufacturer name (e.g. Intel, AMD, Asus, Corsair).
precioDECIMAL(5,2)Unit price in US dollars with two decimal places. The maximum representable value is 999.99.
imagenVARCHAR(30)Filename only, without a path prefix (e.g. acc393.jpg). The serving path is prepended by the template.
descripcionTEXTFull product specification text. Uses utf8 COLLATE utf8_spanish2_ci to support Spanish characters such as accented vowels and ñ.
Seed data: 31 products are seeded across the three categories — 10 processors (id_cat = 1), 10 motherboards (id_cat = 2), and 9 RAM modules (id_cat = 3). One test row (id_producto = 30) was inserted with placeholder data (adasd) and belongs to a non-existent category (id_cat = 4).

usuario table

Stores registered shopper accounts. Each row maps to exactly one login identity. The idusuario primary key is what gets stored in $_SESSION['idusuario'] on successful login.
CREATE TABLE usuario (
  idusuario    INT(3)      NOT NULL AUTO_INCREMENT,
  nickname     VARCHAR(40) NOT NULL,
  nombre       VARCHAR(40) NOT NULL,
  apellido     VARCHAR(40) NOT NULL,
  pais         VARCHAR(50) NOT NULL,
  ciudad       VARCHAR(50) NOT NULL,
  contrasena   VARCHAR(40) NOT NULL,
  fechaingreso VARCHAR(40) NOT NULL,
  PRIMARY KEY (idusuario)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
ColumnTypeDescription
idusuarioINT(3) AUTO_INCREMENT PKUnique user identifier. Stored in $_SESSION['idusuario'] after login.
nicknameVARCHAR(40)Login username. Stored in $_SESSION['usuario'] after login. Not enforced as unique by a database constraint.
nombreVARCHAR(40)User’s first name, collected at registration and used in email greetings.
apellidoVARCHAR(40)User’s last name.
paisVARCHAR(50)Country of residence, collected during registration.
ciudadVARCHAR(50)City of residence, collected during registration.
contrasenaVARCHAR(40)Login password stored as plain text.
fechaingresoVARCHAR(40)Registration date stored as a freeform formatted string (e.g. 27 de Noviembre de 2011). Not a DATE or TIMESTAMP column.
Passwords in the usuario table are stored as plain text. Anyone with read access to the database can see every user’s password immediately. In any real application you must hash passwords before storing them — use PHP’s built-in password_hash() and password_verify() functions instead of comparing raw strings.

compra table

Defines the schema for recording individual purchase line-items. The table exists in the database with proper indexes on both foreign key columns, but no PHP page in this project writes to it — orders are handled externally by PayPal, and there is no write-back step after payment confirmation.
CREATE TABLE compra (
  idcompra    INT(4)    NOT NULL AUTO_INCREMENT,
  id_producto INT(6)    NOT NULL,
  idusuario   INT(3)    NOT NULL,
  fecha       TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (idcompra),
  KEY id_producto (id_producto),
  KEY idusuario (idusuario)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
ColumnTypeDescription
idcompraINT(4) AUTO_INCREMENT PKUnique purchase record identifier.
id_productoINT(6)References productos.id_producto. Indexed but not enforced as a foreign key.
idusuarioINT(3)References usuario.idusuario. Indexed but not enforced as a foreign key.
fechaTIMESTAMPAuto-set to the current timestamp when a row is inserted, and updated on every subsequent modification.
The compra table exists in the schema but is never written to by any PHP page in this project. Purchases are processed externally through PayPal — final.php builds the order email and then auto-submits a hidden PayPal form via JavaScript. There is no PayPal IPN (Instant Payment Notification) handler or webhook that writes a confirmed order back to this table. The compra dump in bd.sql is empty (AUTO_INCREMENT=1).

Relationships

The four tables relate to each other as follows:
  • categoriasproductos (one-to-many via id_cat): each category contains multiple products. The relationship exists at the application level; there is no FOREIGN KEY constraint because the MyISAM storage engine does not enforce them.
  • usuariocompra (one-to-many via idusuario): a single registered user can have many purchase records. Again, the key index exists but the constraint is not enforced by the engine.
  • productoscompra (one-to-many via id_producto): a single product can appear in many purchase records.
Because all four tables use the MyISAM storage engine, referential integrity is entirely the application’s responsibility. Deleting a category row, for example, will not automatically null-out or cascade-delete related productos rows.

Character set note

All four tables declare DEFAULT CHARSET=latin1, which covers Western European characters and most common punctuation. The one exception is the descripcion column in productos, which overrides the table-level charset:
`descripcion` TEXT CHARACTER SET utf8 COLLATE utf8_spanish2_ci NOT NULL
The utf8_spanish2_ci collation treats ch and ll as single characters for sorting purposes (traditional Spanish dictionary order) and provides correct case-insensitive comparison for characters like á, é, í, ó, ú, and ñ found throughout the product description text.

Build docs developers (and LLMs) love