Skip to content

Violate foreign key constraints. #11

@SyedTauhidUllahShah

Description

@SyedTauhidUllahShah

For the "CREATE TABLE Order_Items (
order_item_id INT PRIMARY KEY,
order_id INT,
product_id INT,
quantity INT,
unit_price DECIMAL(10, 2),
FOREIGN KEY (order_id) REFERENCES Orders(order_id),
FOREIGN KEY (product_id) REFERENCES Products(product_id)
);"

The product table have only 16 id's, which means that when inserting the data into the Order_Items table beyond 16 entries, it will cause an issue.

This is because the FOREIGN KEY constraint in the Order_Items table ensures that every product_id referenced in Order_Items must already exist in the Products table. If the Products table only has entries up to product_id 16, any INSERT statement in Order_Items that references a product_id higher than 16 will violate the foreign key constraint and result in an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions