What are the advantages of using separate tables for different entities in a relational database, such as creating a table for subjects and another for students in the given scenario?
Using separate tables for different entities in a relational database allows for better organization and structure of data. It also helps in avoiding data redundancy and maintaining data integrity. This approach makes it easier to query and retrieve specific information related to each entity.
CREATE TABLE subjects (
id INT PRIMARY KEY,
name VARCHAR(50)
);
CREATE TABLE students (
id INT PRIMARY KEY,
name VARCHAR(50),
subject_id INT,
FOREIGN KEY (subject_id) REFERENCES subjects(id)
);