This document provides an ER Diagram for a database and explains the implementation of the tables using SQL statements. It also includes insert statements for sample data.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Assessment 2: Database March 31 2019 Student ID: Student name:
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Report ER Diagram Assumptions 1.A student can have more than one subject. 2.A teacher can monitor only one school at a time. The monitor can be changed in future.
gender VARCHAR(1) NOT NULL, dob datetime NOT NULL, schoolCode VARCHAR(20) NOT NULL, PRIMARY KEY (studentNumber), FOREIGN KEY (schoolCode) REFERENCES school(schoolCode)) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS teacher ( tfn VARCHAR(20) NOT NULL, FirstName VARCHAR(50) NOT NULL, LastName VARCHAR(50) NOT NULL, gender VARCHAR(1) NOT NULL, qualification VARCHAR(100) NOT NULL, schoolCode VARCHAR(20) NOT NULL, PRIMARY KEY (tfn), FOREIGN KEY (schoolCode) REFERENCES school(schoolCode)) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS subjects ( title VARCHAR(20) NOT NULL, subjectType VARCHAR(50) NOT NULL, PRIMARY KEY (title)) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS manager ( tfn VARCHAR(20) NOT NULL,
schoolCode VARCHAR(20) NOT NULL, startDate date NOT NULL, PRIMARY KEY (tfn), FOREIGN KEY (tfn) REFERENCES teacher(tfn), FOREIGN KEY (schoolCode) REFERENCES school(schoolCode)) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS subjectSudent ( studentNumber VARCHAR(20) NOT NULL, title VARCHAR(20) NOT NULL, PRIMARY KEY (studentNumber, title), FOREIGN KEY (studentNumber) REFERENCES student(studentNumber), FOREIGN KEY (title) REFERENCES subjects(title)) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS subjectTeacher ( tfn VARCHAR(20) NOT NULL, title VARCHAR(20) NOT NULL, teachingHours double NOT NULL, PRIMARY KEY (tfn, title), FOREIGN KEY (tfn) REFERENCES teacher(tfn), FOREIGN KEY (title)
REFERENCES subjects(title)) ENGINE = InnoDB; Insert Statements Insert into School Table insert into school (schoolCode, schoolName, address, phone) values ('S101','St. Marry','10 Soldier Street, TAS','6745883838'), ('S102','St. Joseph','5 Yellow Street, NJ','6745883838'), ('S103','St. Thomson','36 White Street, TAS','6745883838'), ('S104','St. Thomas','10 Mango Street, TAS','6745883838'), ('S105','St. Francis','11 Soldier Street, TAS','6745883838'); Insert into Student Table insert into student (studentNumber, FirstName, LastName, gender, dob, schoolCode) values ('101','John','Smith','M',STR_TO_DATE("07-04-1999","%m-%d-%Y"),'S101'), ('102','WILLIAM','Jainani','M',STR_TO_DATE("04-05-1990","%m-%d-%Y"),'S102'), ('103','Rose','Kelly','F',STR_TO_DATE("01-01-1989","%m-%d-%Y"),'S101'), ('104','Lee','Karporrzis','M',STR_TO_DATE("03-04-1999","%m-%d-%Y"),'S101'), ('105','Noel','Ritter','M',STR_TO_DATE("07-09-1979","%m-%d-%Y"),'S101');
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.