Preparing your workspace
Normalization organizes relational data to reduce unnecessary duplication and maintain consistent relationships.
Normalization is a set of design principles used to structure relational data. Instead of repeatedly storing the same information in many rows, related data can be placed into separate tables and connected with keys. Common concepts include first normal form, second normal form, and third normal form. Real projects may sometimes intentionally denormalize selected data for performance, but that should be a deliberate choice based on actual requirements.
Instead of storing the instructor's full name in every course row, an instructors table can store that information and courses can reference the instructor ID.
CREATE TABLE instructors ( id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100) NOT NULL ); CREATE TABLE courses ( id INT PRIMARY KEY AUTO_INCREMENT, title VARCHAR(150) NOT NULL, instructor_id INT NOT NULL, FOREIGN KEY (instructor_id) REFERENCES instructors(id) );
Instructor information is stored separately and courses reference the instructor through instructor_id.