How can product categories and properties be effectively managed in a PHP-based shop database?

To effectively manage product categories and properties in a PHP-based shop database, you can create separate tables for categories and properties, and establish relationships between them using foreign keys. This allows for easier organization, retrieval, and modification of product data within the database.

// Create categories table
CREATE TABLE categories (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(50) NOT NULL
);

// Create properties table
CREATE TABLE properties (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(50) NOT NULL
);

// Create products table with foreign keys for category and property
CREATE TABLE products (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    category_id INT,
    property_id INT,
    FOREIGN KEY (category_id) REFERENCES categories(id),
    FOREIGN KEY (property_id) REFERENCES properties(id)
);