Press "Enter" to skip to content

SQL Should you store arrays with an unknown length as a table? [closed]

        This is my first day of SQL so this question might be a little dumb. I have a student table wich I filled with students, now every student should have a table with the following columns score, max_score, grade_name etc.
Is it convention to dynamically add tables for every student I add or is there a better way? Thanks for any insights! Incase you need, here is my code I've written:
DROP DATABASE school_db;
CREATE DATABASE school_db;
USE school_db;

CREATE TABLE school_table (
    id int UNIQUE AUTO_INCREMENT,
    
    school_name VARCHAR(255) UNIQUE,
    address VARCHAR(255) UNIQUE,
    is_catholic bool,
    
    PRIMARY KEY (id)
);
CREATE TABLE teacher_table (
    id int UNIQUE AUTO_INCREMENT,
    teacher_name VARCHAR(255),
    
    PRIMARY KEY (id)
);
CREATE TABLE class_table (
    id int UNIQUE AUTO_INCREMENT,
    teacher_id int,
    school_id int,
    
    PRIMARY KEY (id),
    FOREIGN KEY (school_id) REFERENCES school_table(id),
    FOREIGN KEY (teacher_id) REFERENCES teacher_table(id)
);
CREATE TABLE student_table (
    id int UNIQUE AUTO_INCREMENT,
    class_id int,
    
    home_address VARCHAR(255),
    age int,
    
    PRIMARY KEY (id),
    FOREIGN KEY (class_id) REFERENCES class_table(id)
);

Be First to Comment

Leave a Reply

%d bloggers like this: