Finding name of class in table and adding him his ID

122
February 11, 2018, at 07:02 AM

I am creating School database and I have two questions for you.

enter image description here

  1. Is the schema of my database good? I think, relations etc.

  2. If I have front-end, where I can add some students, how I do adding class, so if I write example C11 I want, that SQL finds C11 in table Class and add him his ID.

enter image description here

I am sorry for my poor English.

Answer 1

Try to think this way, If you have school, then you'll have Classes. IF you have classes, then you'll students, if you have students, then you'll have teachers, if you have teachers, then you'll have subjects and so on. You see how things makes sense ? everything is connected to each other, and everything is under one school.

So, The School should have Classes, Teachers, and Students. Each Teacher should have his own Subjects that he teaches, his students, and his classroom. Students should have their Classes, Subjects, Grades, and Teachers.

So The relations should something like this :

Teachers and Students tables will have ONE AUTO INCREMENT Primary key (teacher_id and student_id)

Subjects should have ONE AUTO INCREMENT Primary key AND ONE FOREIGN KEY (teacher_id). This is because the subjects will be linked directly to the teachers. for each subject, you'll know the teacher who teaches it.

Classes will have Teachers, Students, and Subjects. So, Claases table will have ONE AUTO INCREMENT Primary key AND three FOREIGN KEY (studtent_id, teacher_id, subject_id). for each class, you'll know its teacher, subject, and students.

Grades will have Students, Subjects, and Teachers. So, Grades will have ONE AUTO INCREMENT Primary key AND three FOREIGN KEY (studtent_id, teacher_id, subject_id). For each grade, you'll know the student, subject, and the teacher who manage it. (you can use studtent_id, and subject_id this one is fine as well, but including teacher_id will be a shortcut of having multiple joins).

Finally, your schema diagram should something similar to this:

As for the second question, this should be done over PHP or any similar approach (Google for some tutorials)

READ ALSO
Can't route in fresh laravel 5.6 installation

Can't route in fresh laravel 5.6 installation

Today I started a fresh laravel installation through composer with this piece of code(just as always):

269
Create page level comment with doxygen

Create page level comment with doxygen

I have an old php project with mainly functions rather than classesI am useing doxygen to generate documentation

133
Removing .php extension in subdirectory

Removing .php extension in subdirectory

I am looking to remove thephp extension from my website URL

132
Measuring the time a page takes to load with PHP?

Measuring the time a page takes to load with PHP?

I'm trying to check how long it took to load my page in PHP, this means created a start and end time and checking the differences at the end of the script

133