php - Implementing a report card generation system

603

I want to create a system inphp andmysql , that is supposed to calculate student grades and display the results, such that the school can print out a report card.

When a teacher logs onto the system, he/she will only see the students he/she teaches

I already have three tables in the database (teachers table,students table,subjects table).

A teacher teaches more than one subject and a teacher teaches more than one class.

How can I implement that in the database?

363

Answer

Solution:

This question is not really appropriate for StackOverflow, but I will try to get you started by providing a first draft for your tables:

Teacher

TeacherId INT NOT NULL Primary key Autogenerated
FirstName VARCHAR(100)
LastName VARCHAR(100)

Student

StudentId INT NOT NULL Primary key Autogenerated
FirstName VARCHAR(100)
LastName VARCHAR(100)

Subject

SubjectId INT NOT NULL Primary key Autogenerated
SubjectName VARCHAR(100)

TeacherXSubject (association between teachers and subjects)

TeacherXSubjectId INT NOT NULL Primary key Autogenerated
TeacherId INT NOT NULL FK -> Teacher
SubjectId INT NOT NULL FK -> Subject

an unique key should be placed on (TeacherId,SubjectId)

Class

ClassId INT NOT NULL Primary key Autogenerated
ClassName VARCHAR(100)

TeacherXClass (classes one teacher may teach)

TeacherXClassId INT NOT NULL Primary key Autogenerated
TeacherId INT NOT NULL FK -> Teacher
ClassId INT NOT NULL FK -> Class

an unique key should be placed on (TeacherId,ClassId)

ClassXStudent (the classes a student may attend)

ClassXStudentId INT NOT NULL Primary key Autogenerated
ClassId INT NOT NULL FK -> Class
StudentId INT NOT NULL FK -> Student
Grade INT    -- type may depend on how the grade looks (numeric vs. A, B, ...)

For the first request: see the students he/she teaches

SELECT S.*
FROM Student S
   INNER JOIN ClassXStudent CxS ON CxS.StudentId = S.StudentId
   INNER JOIN TeacherXClass TxS ON TxS.ClassId = CxS.ClassId
WHERE T.TeacherId = <current teacher id>

Give it a try and come back with more targeted questions :).

People are also looking for solutions to the problem: php - How to show "no results found" in the search result is empty?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.