Skip to main content
This guide covers importing the database schema, configuring the connection, and verifying your setup.

Prerequisites

Complete the Installation guide before proceeding
XAMPP Apache and MySQL services must be running

Database Overview

The TiendaRopa database includes 8 interconnected tables for managing clothing inventory:

prenda

Main inventory table with clothing items

categoria

Categories: Caballero, Dama, Infantil, Deportiva, Accesorios

talla

Size management (ch, m, g, ech, eg)

color

Color catalog for garments

empleado

Staff members (gerente, empleado)

proveedor

Supplier information

movimiento_stock

Stock movements (entrada, salida, ajuste)

actualizacion

Price change history

Step 1: Access phpMyAdmin

1

Open phpMyAdmin

With XAMPP running, navigate to:
http://localhost/phpmyadmin
You should see the phpMyAdmin interface.
2

Login (if required)

Default XAMPP credentials:
  • Username: root
  • Password: (leave empty)
If you’ve secured your MySQL installation, use your custom credentials

Step 2: Import the Database

The TiendaRopa.sql file contains the complete database schema and sample data.
1

Locate the SQL File

Find TiendaRopa.sql in your project directory:
CRUD Tienda Ropa/TiendaRopa.sql
2

Import via phpMyAdmin

In phpMyAdmin:
  1. Click on the Import tab in the top menu
  2. Click Choose File and select TiendaRopa.sql
  3. Ensure format is set to SQL
  4. Scroll down and click Go/Import
You should see a success message: “Import has been successfully finished”
3

Verify Database Creation

Look at the left sidebar. You should now see a database named tienda_ropa.Click on it to expand and verify all 8 tables were created:
  • actualizacion
  • categoria
  • color
  • empleado
  • movimiento_stock
  • prenda
  • proveedor
  • registro
  • talla
The SQL file automatically creates the database. If a tienda_ropa database already exists, you may want to drop it first to avoid conflicts:
DROP DATABASE IF EXISTS tienda_ropa;

Step 3: Understand the Database Schema

Core Tables

The main inventory table storing all clothing items.
CREATE TABLE `prenda` (
  `id_prenda` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(100) NOT NULL,
  `precio` decimal(10,2) NOT NULL,
  `stock_actual` int(11) DEFAULT 0,
  `id_categoria` int(11) NOT NULL,
  `id_talla` int(11) NOT NULL,
  `id_color` int(11) NOT NULL,
  PRIMARY KEY (`id_prenda`)
);
Key Relationships:
  • Links to categoria (clothing type)
  • Links to talla (size)
  • Links to color (color)

Step 4: Configure Database Connection

The database connection is managed through db.php using PDO.

Default Configuration

tienda_ropa/db.php
<?php
$host = "localhost";
$db_name = "tienda_ropa";
$username = "root"; // Usuario por defecto en phpMyAdmin
$password = "";     // Contraseña por defecto vacía en XAMPP

try {
    $conn = new PDO("mysql:host=$host;dbname=$db_name;charset=utf8", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
    echo "Error de conexión: " . $e->getMessage();
}
?>

Custom Configuration

Only modify db.php if you’ve customized your MySQL installation with:
  • A different root password
  • A custom database user
  • A non-standard port
  • Remote database access
If needed, update the connection parameters:
<?php
$host = "localhost";
$db_name = "tienda_ropa";
$username = "root";
$password = "your_mysql_password"; // Add your password here

try {
    $conn = new PDO("mysql:host=$host;dbname=$db_name;charset=utf8", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
    echo "Error de conexión: " . $e->getMessage();
}
?>

Step 5: Verify Database Tables

1

Check Table Structure

In phpMyAdmin, click on the tienda_ropa database and verify all tables have data:
TableExpected Rows
categoria5
color5
talla5
empleado5
proveedor5
prenda15+
movimiento_stock20+
actualizacion6+
registro5+
2

Browse Sample Data

Click on any table name, then click Browse to view the sample data.For example, clicking on prenda should show items like:
  • Camisa Oxford Slim
  • Pantalón Jean Clásico
  • Vestido de Gala Rojo
  • Playera Deportiva Pro
3

Verify Foreign Keys

Click on the Structure tab for the prenda table.Under “Relation view”, verify foreign key constraints are active:
  • id_categoriacategoria(id_categoria)
  • id_tallatalla(id_talla)
  • id_colorcolor(id_color)

Step 6: Test the Application

1

Access the Application

Open your browser and navigate to:
http://localhost/tienda_ropa
or
http://localhost/tienda_ropa/index.php
2

Verify Homepage Loads

You should see:
  • The TiendaRopa navigation bar
  • An “Inventario” (Inventory) table
  • Sample garments with prices, stock, categories, sizes, and colors
  • Search functionality
  • Sortable columns
If you see the inventory table with data, your database setup is complete!
3

Test CRUD Operations

Try basic operations to ensure everything works:
  1. Create: Click “Nueva Prenda” to add a new garment
  2. Read: View the inventory table
  3. Update: Click “Editar” on any item
  4. Delete: Click “Borrar” (you’ll get a confirmation)

Understanding Sample Data

The database includes realistic sample data to help you get started:

Categories (categoria)

  • Caballero: Men’s formal, informal, casual and formal wear
  • Dama: Dresses, blouses and seasonal trends for women
  • Infantil: Comfortable and durable clothing for children 2-12 years
  • Deportiva: High-performance technical sportswear
  • Accesorios: Accessories like belts, scarves and basic jewelry

Sizes (talla)

  • ch: Chico (Small)
  • m: Mediano (Medium)
  • g: Grande (Large)
  • ech: Extra Chico (Extra Small)
  • eg: Extra Grande (Extra Large)

Colors (color)

  • Negro Nocturno (Night Black)
  • Blanco Pureza (Pure White)
  • Azul Marino (Navy Blue)
  • Rojo Pasión (Passion Red)
  • Gris Oxford (Oxford Grey)

Employees (empleado)

Sample staff with roles:
  • Gerente (Manager): Karina Sánchez, Kennia De luna, Mariana Juárez
  • Empleado (Employee): Miguel Esparza, Guadalupe Hernández

Sample Garments

Camisa Oxford Slim

Price: $450.00
Stock: 25
Category: Caballero
Size: M | Color: Azul Marino

Vestido de Gala Rojo

Price: $1,350.00
Stock: 10
Category: Dama
Size: M | Color: Rojo Pasión

Playera Deportiva Pro

Price: $350.00
Stock: 50
Category: Deportiva
Size: CH | Color: Blanco Pureza

Sudadera Infantil Hoodie

Price: $400.00
Stock: 15
Category: Infantil
Size: M | Color: Gris Oxford

Troubleshooting

Your MySQL root password doesn’t match the one in db.php.Solution: Update the password in db.php or reset your MySQL root password:
ALTER USER 'root'@'localhost' IDENTIFIED BY '';
FLUSH PRIVILEGES;
The database wasn’t created during import.Solution: Manually create it in phpMyAdmin SQL tab:
CREATE DATABASE tienda_ropa DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Then re-import TiendaRopa.sql.
The INSERT statements may have failed.Solution: Check phpMyAdmin’s import log for errors. Ensure:
  1. The SQL file is complete and not corrupted
  2. You have sufficient MySQL privileges
  3. No foreign key constraint errors occurred
Check these common issues:
  1. MySQL not running: Start it in XAMPP Control Panel
  2. Wrong credentials: Verify db.php matches your MySQL setup
  3. PDO not enabled: Check PHP extensions in php.ini
Test connection manually:
<?php
try {
    $conn = new PDO("mysql:host=localhost;dbname=tienda_ropa", "root", "");
    echo "Connection successful!";
} catch(PDOException $e) {
    echo "Error: " . $e->getMessage();
}
?>
This happens if you try to insert/update data that violates relationships.Solution: The SQL file creates tables in the correct order. Always:
  1. Drop all tables if re-importing
  2. Import the complete SQL file
  3. Don’t manually modify table structure without updating constraints

Database Maintenance Tips

Backup Regularly: Export your database frequently from phpMyAdmin (Export tab → SQL format)
Use Transactions: The application uses PDO with exception mode for safe database operations
Monitor Stock Levels: The movimiento_stock table tracks all inventory changes automatically
Price History: The actualizacion table maintains complete price change history for auditing

Next Steps

Core Features

Learn how to manage your clothing inventory

User Guide

Learn how to use the system effectively

Database Schema

Explore the complete database structure

Database Tables

View detailed table documentation
Your TiendaRopa installation is now complete and ready to use!

Build docs developers (and LLMs) love