Simplifying database records
One teacher from the high school heard rumblings about efforts to better organize student records. He would like to organize student grades in his courses. The teacher proposes the following table structure for the test_grades
table:
CREATE TABLE test_grades (
student_id INTEGER NOT NULL,
course_name VARCHAR(50) NOT NULL,
grades TEXT NOT NULL
);
Each record represents a student from one of the teacher's classes identified by the student's id, the course name, and the student's test grades. The teacher finds that managing the database with this structure is difficult. Inserting new grades requires a complex query. In addition, doing calculations on the grades is not very easy. In this exercise, you will help to put this table in 1st Normal Form (1NF).
This exercise is part of the course
Creating PostgreSQL Databases
Exercise instructions
- Define a new version of the table with the name
test_grade
. - Include
student_id
andcourse_name
columns as defined in thetest_grades
table. - In place of a
grades
column, include a numeric column namedgrade
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Create the test_grade table
___ ___ ___ (
-- Include a column for the student id
___ ___ NOT NULL,
-- Include a column for the course name
___ ___ NOT NULL,
-- Add a column to capture a single test grade
___ ___ NOT NULL
);