In PHP, what are some key principles of database normalization that should be considered when designing tables for booking systems?
One key principle of database normalization in designing tables for booking systems is to reduce redundancy by breaking down data into separate tables to avoid duplication and inconsistencies. Another principle is to ensure data integrity by using foreign keys to establish relationships between tables. Additionally, it is important to organize data logically and efficiently to improve query performance.
CREATE TABLE bookings (
booking_id INT PRIMARY KEY,
user_id INT,
event_id INT,
booking_date DATETIME,
FOREIGN KEY (user_id) REFERENCES users(user_id),
FOREIGN KEY (event_id) REFERENCES events(event_id)
);
CREATE TABLE users (
user_id INT PRIMARY KEY,
username VARCHAR(50),
email VARCHAR(100)
);
CREATE TABLE events (
event_id INT PRIMARY KEY,
event_name VARCHAR(100),
event_date DATE
);