Database design a simple database for a functional school - mysql

So i am having a little trouble in coming up with the entity-relationships for my database however i have some of the design process done be that of minimum caliber. The database will be created so that students can have many courses many to many relationship (obvious i know). The database will need to keep track of homework and attendence daily. However, classes can be just one day of the week or many days.
advisors->(advisorid, firstname, lastname, phone , email)
students->(studentid,firstname, lastname, phone, email)
courses->(courseid, description, startdate, statetime, room)
studentscourses->(studentid, courseid)
Here i am stuck, i am thinking of creating a calendar table, but how will i correlate the data to the homework table and with attendance. If any suggestions that would be great criticism is welcome.

You need to create some more entities to achieve an efficient database design. One solution would be:
Attendance(id,student_id,course_id,date)
Homework(id, course_offering_id, date) -- course_offering_id: primary key of student courses
-- since many to many relation lies between homework and student
Homework_Student(id, homework_id, student_id)

U can expand the studentscourses table to add more columns like
Studentcourses->(studentid,courseid,attendence(bool),datetime,homework(text),previoushomework(bool))
attendence will be true if the student is present on that particular date and time at which the course is scheduled.
datetime-> the date and time of the course
homework-> this shows the homework that student gets
previoushomework-> this will be true when the student has completed the homework given the previous time
This is the simplest and most compact table design u can have with this project and you can also make other relational tables according to your needs
Hope that might solve your problem

Related

Limit one userID to a specific date in table

Hey guys i am currently working on a school assignment.
I need to make a database that registers school students and their sport events. But with a twist:
One student can only have one event per day. But there can be multiple different students on each day.
I have made the date a primary key since my teacher said that was the solution, but it isn't.
Now i can plan one event on a date, and nothing else on that date.
This is my database:
This is my first time asking a question about mysql so please correct me if i'm doing anything wrong.
Thanks!

SQL attendance database design

I am currently designing a database in mariaDb that will be used in a Meteor app (woth sequelize orm) for tracking the attendance of students in a school.
I'm not sure is the most effective way as there are few exceptions on my case:
teachers can move and reorganise their schedule as they please, and also because the student pay for each lesson (and certain type of absence), I can't use a "exclusion way" (eg only record absence, so no record = present)
the most important query needed is attendance per student, and I need to have it every time I open my app for every student.
second most important is a monthly attendance per teacher. (This one is needed on demand)
(not db related) I need to track the students presence by groups of 10 (every lessons they have to pay again)
The estimated starting size is 20 teachers, 250 students, 500 attendance/week, (every student has two lessons) 37 weeks,( max size double students and lessons).
Is running 250 queries (find) on a 20000row table time consuming?
Is on student table having a lesson_counter field that is updated every time an attendance is recorded a good idea?
Many thanks!
UPDATE:
there is a possible optimization to be made? This should represent a base for a possible email and invoice system both towards students and teachers
There are many possible improvements to your design. Let me start by answering your specific questions:
Is running 250 queries (find) on a 20000row table time consuming?
No. On modern hardware, querying 20.000 rows is going to be fast. If you have a decent indexing strategy, the queries should return in 10s of milliseconds.
Is on student table having a lesson_counter field that is updated
every time an attendance is recorded a good idea?
No, it's a bad idea - on the assumption that you want a report for each student showing when they attended or missed a lesson, you have to store that data anyway. Keeping a counter is duplicating that information.
I suggest a design like the following.
An "attendance" and "absence" are logically separate things; you can model them in a single table with a flag. I've modeled them separately because I see them as different things in the business domain, with different attributes (absence has a reason code), and potentially different behaviour (for instance, an absence might have a workflow for sending an email). I prefer to have things that are logically separate in separate tables.
Student
-------
student_id
name
...
Lesson
------
lesson_id
subject
teacher_id (if only one teacher can teach a lesson)
....
enrollment
---------
lesson_id
student_id
start_datetime (or you might have the concept of "term")
end_datetime
lesson_session
-------
lesson_session_id
lesson_id
start_datetime
end_datetime
location
teacher_id (in case more than one teacher can teach a lesson)
attendance
--------
lesson_session_id
student_id
absence
------------
lesson_session_id
student_id
reason (or might be a foreign key to reasons table)

What's a good DB design schema for advanced attendance?

First off, I did read this post What is a good database design (schema) for a attendance database? but it doesn't fit my needs and I'm struggling to adapt it to my scenario.
I will try to explain in brief.
Let's take a school (sort of):
School has courses with a starting and an ending date
Students can be "subscribed" to multiple courses
A subscription doesn't necessary start from the beginning nor ending at the end of the course.
The student can be attended punctually (independently of the subscription) or transferred punctually in an another course.
I came with this design in mind:
My idea:
When transferring punctually a student, I can change the course_id
I can create an attendee without subscription_id, on demand
My problem:
With this design, It's seems over complicated and to see who's coming to a course, I see only two solutions.
Count the number of subscription, add the number of attendees present, remove the number of attendees absent.
Use a queue worker to create all the attendees and count the number of present attendee.
What would it be the easier way or what better schema could I use?

Creating a database system for a high school containing students records

I am building a student database for a high school. I have been able to solve most of my problems with the exception of one.
The tables I currently have are for records of the current school term. I am trying to find a way to permanently keep records for the first term, second term, third term and even after the student graduates. Student information will still be stored in the database permanently.
Please can anyone give me an idea of how I should build it?
Add a field "Term", where you write the term, which this record is for.
I think the most logical way is to have Year (calendar year) and Term (semester term: Spring, Summer, Fall) fields associated to each student. This way you could fully distinguish attendance by either calendar year or term. For graduation status you could add either graduation flag or graduation date, or both.
ADDED:
In response to comment below. Yes, I think it does make more sense to track prospective students and enrolled academic students separately. You either can track those in a stand along table or implement additional fields to the existing table. As an example, you could have a field person_status as enrolled, graduated, prospective.
Your ultimate structure really depends on what level of detail you try to achieve.

mysql database logic

My question is more of trying to understand what and how I can get something done. Here's the thing:
I got a job to build this application for a school to manage student bio data, work-out and handle student information and basic finance management.
Based on requirements I got from meets with my client, I have an ERD of a proposed MySQL Database with 23 different tables. The one part I would like to understand quickly is displaying data based on school terms. There are 3 terms in a year, each with its own summaries at the end of each term. At the end of 3 terms, a year has gone by and a student is promoted or demoted.
So my question is, how can I render my data to show 3 different terms and also to create a new year working out how to either promote a student or make the student repeat the class its in?
23 different tables? I'd like to see that model.
I don't think you should have one table per term. You'll have to keep adding tables every term, every year.
Sounds like a transcript table should have term and year columns that are incremented or decremented as a student progresses through. It should also have a foreign key relationship with its student: it's a 1:1 between a student and their transcript.
I would have a separate transcript table because I'd prefer keeping it separate from basic personal information about a student. A transcript would refer to the courses taken each term, the grade received for each, and calculate overall progress. If I queried for the transcript for an individual student, I should be able to see every year, every term, every course, every grade in reverse chronological order.