How can I calculate some students in my database? - database

I have such entities:
There are teachers, students, languages, courseGroups and a junction table GroupStudent
Every courseGroup can have only one teacher and one language, but every teacher and language can have multiple courses.
Also, there are students. Every student can have a few courses and every course can have a few students.
I'm not sure about this. Is it the right scheme?
Why do I think so?
I have a task. I have to calculate the number of students in every group, who study English.
The problem: I don't know how to find students who study English. It would be easier if student could have only one course. Then I'd have just check all English courses. However, student can have a few courses.
Example: Student Stepan has (CourseGroupid=1) an English course and (CourseGroupid=2) a Spanish course. I have to calculate this student for both groups.
P.S. I'd be very grateful if you'd just hit me is it possible to complete the task with this database or how to remake it :)

Do a DISTINCT select on Students.Id to get every student at max once. Then JOIN GroupStudent, CourseGroups and Languages. Lastly add a WHERE clause on Languages.Name = 'English'. You should be able to figure out the exact SQL on your own

Related

A table with two keys in Firebase

I have a Firebase database for recording grades of students to exercises. There is a "students" object that holds all student details, and an "exercises" object that holds all exercise details. Now the question is where to put the grade that a certain student scores in a certain exercise?
When a student enters the system, it needs to show the grades of this student to all exercises, so it makes sense to put all grades in the "student" object.
When a lecturer enters the system, it needs to show the grades of all students to a particular exercise, so it makes sense to put all grades in the "exercise" object.
So far, I put the grades in both places, but it lead to bugs, and apparently it is a design bug since the data is duplicated.
In an SQL database, I would just create a separate table called "grades", and have both "student_id" and "exercise_id" as keys in that table. This way it is easy to find all grades either by student_id or by exercise_id.
How can I do this in Firebase?
think i would add all studentIds and excerciseIds into a grades collection, and just have all their grades their, and probaly duplicate extra the data needed from student collection + excercise as you suggest similar to sql approach.
if not that i would probaly checkout support for subcollectin queries as i belive its on the way? that way each excercise could have the student information as subcollection, either way duplicate the data and think like sql views.

Correct use of an association class

I am new to using UML and I am not sure if my diagram is correct. I would like some advice from someone more experienced than me.
The statement of my problema says:
Students study courses and each student can take several courses "studies" each. Any course can have more than one student studying it.
Students, who are identified by a numerical code, have a name, date of birth and one or more nationalities.
A student who studies can receive scholarships.
A Student can recieve more than one scholarship per course. And an
individual scholarship can be given to more than one student. The
scholarships have a numeric code, which identifies them, a name, a
base amount and different conditions to be fulfilled at the time of
the assignment.
My proposal is the following:
What I want is to represent students, grants and the courses the student takes, and I am not sure if I should use an associative relation or a ternary relation.
Can anybody confirm if my proposal UML diagram is the right one?
The only statement directly relating students, courses & grants is the unclear "[a s]tudent can receive more than one grant per course".
It only actually says that each student-course pair can have more than one associated grant. (Maybe the author of the assignment thought that that "per" sentence is saying more than that, but it's not.) It doesn't say of a student whether their grants depend on their courses, and if so how. Your design is best when given a triplet you can't tell anything about any other triplet. The design with Takes(student,course) & Receives(student, course, grant) with th FK (foreign key) {student, course} from Receives to Takes is best when if you know a student & course pair then you know its grants. If grants are given to a student independently of courses then a design with Takes(student,course) & Receives(student,grant) is enough.
Clarify with your instructor.
Almost. The lozenge (or diamond) shaped element is itself an association class which associates all connected classes. What you want it a simple association class between Student and Studies like this:
The Scholarship represents the exams passed by the students in specific studies. The association class relation is indicated by the dashed line linked to the association (which has a m-n multiplicity).
Before you get to any attributes, I don't see a correlation between the nouns in the problem statement and your classes. I would expect to see the following classes:
Student
Course
Nationality
Scholarship
I would also expect to see an association class, called CourseEnrollment, that would have the following italicized properties at the ends of the association:
Student studiedCourse [1..*] Course
Course studyingStudent [1..*] Student
That association class would have yet another association with Scholarship, called ScholarshipAward, that would have the following italicized properties at the ends of the association:
CourseEnrollment awardedScholarship [0..*] Scholarship
Scholarship receivingCourseEnrollment [0..*] CourseEnrollment
With this arrangement, a Scholarship can be awarded to a combination of Student and Course.

Class Scheduling to Boolean satisfiability [Polynomial-time reduction] Final Part

I'm working since few weeks now on a project really interesting but unfortunately with a very complex background.
I already asked 3 questions :
Class Scheduling to Boolean satisfiability [Polynomial-time reduction] Final Part (here)
Class Scheduling to Boolean satisfiability [Polynomial-time reduction] part 2
Class Scheduling to Boolean satisfiability [Polynomial-time reduction]
in both of them, I get my answer (thank you again #Amit) but now arrived the final part, who will make this project useable :)
I for now can manage :
N time-intervals.
C courses.
T teachers.
S rooms.
My constraints are the follow:
2 teachers cannot be in the same room in the same time.
2 courses cannot be in the same room in the same time.
Teachers can teach only specific courses.
Some courses can happen only on specific time-intervals.
So this is for now, my result :
But here comes the final part that I want to add : I want to manage group of students, with the following constraints :
A group has only some courses to do.
2+ groups can be in the same room in the same time only for specific courses (like Magistral course for example)
Again, I success to isolate the constraint, but I have no idea on how to transform this constraint into a "time-intervals should not overlap" constraint.
Thanks in advance,
Best regards,
Since a student can only be in one place at a time:
Lectures for courses attached to the same student group should not overlap in time.
Edit:
There should be no constraint on different student groups overlapping. If you have such a constraint you should remove it!
The constraints are on courses. If you schdeule a lecture for course A, then it may not overlap a lecture for any other course for the student group(s) that attend course A. It may also not overlap any other course held by the same teacher.
So, you have a many-to-many relationship between students and courses and a many-to-many relationship between teachers and courses.
You want to schedule a number of lectures for each course with the constraint that no teacher and no student has overlapping lectures.
Regarding
2+ groups can be in the same room in the same time only for specific courses (like Magistral course for example)
If the groups may not mix, then it is not the same course (even though the subject may be the same). So if two student groups can not mix for Java, then you need to model it as two separate courses, Java group1 and Java group2.

Database Schema for Student Report

I am trying to create a database schema for creating an online grade report. The report contains the name of the school, the name of the student, the name of the student’s teacher, the number of absent days, the number of tardy days, the student’s current overall grade, and the name of all assignments completed by the student including the date, category, and score for each of those assignments. The following is what I’ve been able to figure out so far. Does anyone have any suggestions about improving this schema?
School (school_id, school_name, course_id)
Course(course_id, course_name, teacher_id, student_id)
Teacher(teacher_id, teacher_name, student_id)
Student(student_id, student_name, grade, absent_days, tardy_days, assignment_id)
Assignment(assignment_id, assignment_name, assignment_date, category, score, course_id)
I suggest you remove the course_id from the school. The student_id from the course & teacher. The assignment_id from the student as described below. In addition I would probably split the assignments into an Assignment and a Mark table.
This results in the schema that a school can have multiple teachers that teach multiple classes that can have multiple assignments. The students belong to a school and can have multiple assignments. This is a pretty simple model and you might consider adding a 'Booking' table in which you store what students have booked what courses. In addition it might be possible that multiple teachers teach a course and teachers work in multiple schools or a course is offered in multiple schools. Just some ideas to think about...
School (school_id, school_name)
Course(course_id, course_name, teacher_id)
Teacher(teacher_id, teacher_name, school_id)
Student(student_id, student_name, absent_days, tardy_days, school_id)
Assignment(assignment_id, assignment_name, assignment_date, category, score, course_id, student_id)
Microsoft provides a sample school database for free. If you find that is helpful:
https://learn.microsoft.com/en-us/ef/ef6/resources/school-database

Database design decision translating requirements to relational models

So I've volunteer to create a Registering system for my local church's education ministry. It should be able to register new students and keep track of their progress. Here are the requirements I've managed to gather:
The educational institution offers several courses.
Courses have a name and description.
Courses are organized in levels. There are several courses per level.
Courses also have requirements (i.e. other courses that need to be taken first).
A student graduates from a level when it has passed all courses of that level.
If a student cannot pass a course, he may repeat it as many times as he wants/needs.
Students can only take one course per semester.
An inactive student is one that isn't enrolled in the current semester.
Teachers will teach only one course per semester. Teachers may teach a different course each semester.
There could be semesters a teacher doesn't teach.
Now, this is my relational model.
![https://dl.dropbox.com/u/10900918/rmodels.jpg][1]
My questions are:
Are there any tables missing?
Looking at the semester + semester_code_description: is this the best way to do this? Under the assumption that a year has 2 semesters and that each semester have the same start and end months (i.e. semester 1: Aug - Dec, semester 2: Jan - May), is semester_code_description table really necessary?
How could I improve the design?
Sorry I didn't include any arrows. The program I'm using is a mess.
Thanks so much for your valuable time in advance.
1) Nice job on your design. I don't see any missing tables - it looks like you covered all of your requirements.
2) The semester_description table makes sense to me, whether or not you need it depends on whether you plan to do anything with that data.
3) The requirement "students can only take one course per semester" would imply that the Has_Taken relationship's primary key should be (student_id, semester_id). As it stands now, I could insert two different courses for the same student and semester. Similarly for the Has_Teached relationship.
Some other thoughts:
The "last_whatever" columns in some of your tables will force some extra processing on your actual application. You will need some mechanism to monitor/update those. Another option would be to derive them from your tables. I can get a student's last_semester by finding the semester with the max year/code.
One last consideration, how stable are these courses/descriptions/levels? I worked at a university for several years and our courses would change on a semester basis, forcing us to save an entire copy of course records for each change because we want a student's record to reflect what they actually took at that time.
Here's a little example in your app. Let's say I graduated level 1. Then a year later, the church adds a new course (Course A) to level 1. I will effectively be un-graduated b/c now there are level 1 courses I don't have (Course A).
This may not matter to you if your courses are pretty stable. Good luck!

Resources