Correct use of an association class - database

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.

Related

How Can I Improve Relationships in My Database?

I'm very new in designing professional database system and making a School Management System in Laravel. I have issues setting my database. How to enroll a student. To know the problem, you must have to read requirement once.
Every Classroom can have minimum 1 or maximum many Section.
Every Section has many list of Courses and Students enrolled in.
Every Classroom has Teacher
The database I am thinking for this is
Student (many-to-many forming Registration ) Classroom
Classroom (many-to-many forming Class_Section ) Section
Section (many-to-many forming Section_Courses ) Courses
or
Student (many-to-many forming Registration ) Classroom
Classroom {class_id, section_id(FK)} (one-to-many ) Section
Section {section_id, course_id} (one-to-many ) Course
The thing I need is that when enrolling a student, I want to register him in the ClassRoom and in any section of that classroom.
A Student can see all the courses in that section.
This makes clear that registration should have section id as well. But if I make relation of a section with registration. It will show all sections.
Kindly suggest me a possible way of designing this database. I'm stuck up here and can't find a better option for it.
Mainly there are three types of relations. They are,
1. one to one
2. one to many
3. many to many
Think about every relation from both ways. For example, you have said that,"Every Section has many list of Courses." Now think it in reverse. Can a course be offered in more than one section? If yes, then it should be a many to many relation. Otherwise it should be one to many.
Similarly think about classroom and section relationship. You have said, "Every Classroom can have minimum 1 or maximum many Section". Now think about it in reverse. Can a section have more than one classroom? If it can have more than one classroom then you need many to many. Otherwise, one to many will be ok.
The main point is if it is "one to many" from both sides then you need a many to many relation.
About showing only courses for that section; don't worry about it. First design the database. Laravel handles relations extremely well. In fact, eloquent relationship is very powerful tool. You can also use polymorphic relation and intermediary relation. Try to read about it from documentation.

4th Normal Form of table not met

Below is a graph of a database to be used to manage university student enrolment and grades across multiple years. Below are the listed requirements for the database
Students must be able to be a part of a class
A class must teach a subject
Each class may have 0 or more courseworks
Each class will have one exam
Each class can be taught by more than one lecturer
Coursework can only be set by one lecturer
Coursework and exams can be marked by different staff than who set them, and the staff member marking it must be able to be identified and recorded.
It is necessary to specify whether an exam taken is being taken for the first time or is a resit
I think the database is now in 4th normal form, and is represented in the table below.
The key represents the primary key for that table, and a green arrow means it is a foreign key.
Can anyone spot any errors or suggest ways to improve it?
Not enough information here to tell whether you are satisfying any Normal Form or not. We can only guess at some dependencies.
For example, "Each class will have one exam" seems to be saying that class→exam. Your Exam table on the other hand satisfies the dependency examID→classID, which is not one of your requirements. I can't tell from your diagram if classID is a candidate key in the Exam table. It also looks like examTaken would not be in 4NF if the classID→examID is one of the dependencies to be satisfied.
From a practical data modelling point of view 4NF is not very important. 5NF is more important. Is this homework? If so I'd suggest you write down the attributes and dependencies before you start drawing a diagram. You seem to have created far more attributes than are suggested by the statement of requirements.
Obviously the cardinality between coursework and courseworktaken cannot be 1:1.
(Why are some lines dotted and others not ?)

How should I make the relation work in this Database model

(I apologies in advance for my English)
I need to make a model of relation.
Normally it a thing we should do in team, but I am stuck to be alone, so I am kind of overwhelm by this
It about a school and it information concerning The Student, The Parents and the Class he want to enroll. Also they keep academic results.
I just can't get an ideal of how I could link them all and avoiding relations problems
http://i.imgur.com/fdwxH8g.jpg
First, I suggest you add a Person table to supertype Parent and Student, and move all the personal and contact information attributes to Person. You're sure to want to add additional information later, and having to duplicate everything for parents, students (and later, teachers and other school staff) gets to be a nuisance.
person (person_id PK, last_name, first_name, sex, birthday, email, address, city, phone_number, cellphone_number)
Next, do you want to record biological parents or caregivers? In schools we normally care about caregivers and their relationship to the student. To record that, you could create a relationship type table:
relationship (relationship_id PK, description)
with entries for father, mother, aunt, grandfather, fostermother, etc. You can then record the relationship between 2 persons like so:
parent (parent_id PK/FK, child_id PK/FK, relationship FK)
If you wanted to record biological parents, you could use:
bioparents (child_id PK/FK, father_id FK, mother_id FK)
with father and mother ids nullable (or decompose into separate tables for father and mother) since we're unlikely to know both parents for all students.
Finally, we get to the business at hand, students. Historical information and alumni are important in schools, so take care to model students over time, not just current students. You need to consider the time resolution for student registrations - are registrations annual, quarterly, or something else? For annual registrations, you could start with:
student (person_id PK/FK, year)
Now, what is a class? Is it something that recurs over time, or are classes with the same name in different years/quarters separate things? Can classes contain learners of different forms/grades/levels, or are they partitions of those? Is a class a grouping of students that attend multiple subjects, or a subject-specific grouping? I'm familiar with two types of classes, which could be called form classes and academic classes, but things may be different in your region of the world.
Using your class table:
class (class_number PK, name, prerequisite, formation_time)
We need to link students to it. If class membership is an annual thing, we can add to the student relation above, e.g.
student (person_id PK/FK, year, class_number FK)
Now, I just made up tables as I went along, but if you want to do this properly, you really should list/model your functional dependencies before you start making up tables. You could look into a formal modeling discipline like Object-Role Modeling, or at least write out simple logical relations in both directions:
a Student has one or more Parents
a Parent has one or more Students
a Class has a Year
a Year has zero or more Classes
a Student has a Class per Year
For non-binary relations, you don't need to write it out in every direction, but you do need to decide which combinations of attributes uniquely determine the others. For example, the combination of Student and Year uniquely determines the Class.
Anyway, that should give you a start.

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.

ER Model (Chen notation)

My assignment is to draw an ER model (by hand) using Chen notation using the specifications below:
http://i57.tinypic.com/73ff2f.png
If you have questions about these specs. I'll play the role of the
client who will resolve them.
The database will serve a university.
Students have id's, names and gpa's. They must have exactly one major,
but they could have minors as well. Each major or minor is a
department which has a unique name and a phone number. For each
student with a minor, we record the date she signed up for it. Faculty
members are associated with a unique department and have id's, names
and office locations. Each internship is held by a particular student
at a particular compain and is supervised by a particular faculty
member. We also keep track of the last term in which that student
registered under that advisor for an internship at that company.
Students may have many internships over time. A given faculty member
may supervise many students at a given company, and she may supervise
a given student at several companies. However, for a given student and
company, there can be only one faculty advisor.
Students, Departments,
Faculty and Companies should be your entity types. Internship should
be a ternary relationship type. The specs should also lead you to some
binary relationship types. Don't add any ingredients to this mix other
than what appear in the specs.
Below is my work:
http://i60.tinypic.com/28rf7tf.jpg
Can anyone please help as I really need a better understanding of this (my professor is AWFUL at explaining this).
You missed (per your assignment's last paragraph) a department entity type. (Box.)
You missed 'Faculty members are associated with a unique department'. That's a relationship between those two entity types. (Diamond with lines to those boxes.)
You could have those major and minor entitie types that are 1:1 with departments. (Your present boxes with each a line to its own diamond each with a line to department.) But (per your assignment's last paragraph not listing them as entities) you could have major being a relationship 'student[s] has a major in department [d]' and similarly for minor. (Lines from student to each of two diamonds each with a line to department.) But the assignment actually says 'each major or minor is a department' so that's major as 'student[s] has major department [d]' and similarly for minor. (Same picture.)
Per your assignment's last paragraph you should make internship a ternary relationship. (Under Chen it's a relationship diamond (possibly with its own properties) formed by 3 lines to entity type rectangles (possibly with their own properties) rather than an entity box.) However, it's not clear exactly when your assignment considers that an internship holds. (It tells us what relationships hold; it's just not clear which one it wants to call interning.) (Although we can look for interpretations consistent with it being ternary.) One is 'student [s] interns at company [c] supervised by faculty member [f]'. But since 'for a given student and company, there can be only one faculty advisor' that notion of internship is more simply characterized by a binary relationship 'student [s] interns at company [c]'. But then you still need a relationship 'faculty member [f] advises student [s] at a company [c]'. So I will suggest that your assignment expects the former. We can add property term. (This is more reasonably called a relationship on student, company, faculty member and date; but E-RM considers relationships to be on entities. Although it all depends on your class's method's particulars.)
(The possibility of multiple reasonable variations is why you should propose a particular design fully handling a particular specification in a SO question.)
A problem with the E-R Model [sic] is that it introduces needless distinctions between entities, reltionships and properties. There is really no distinction between a relationship instance and an entity. Eg: Here we could just as well have an internship be per above an entity in a 4-way relationship plus property. Eg: Your assignment says 'each major or minor is a department'. But a major or minor isn't a department. A major or minor could be considered a subject, which would be the subject after which a department is named or the subject of the degree offered by a department. Or we could just have relationships in which a department participates but the relationship is about that department's subject or name or degree being a major or minor.
(If an internship as relationship participated in its own relationships I don't know how your instructor's particular method would keep the further lines organized. Some methods add internship entities (box) 1:1 with relationships (diamond); then some methods specially associate the entity type with the relationship as a reification while some make the relationship 4-way by including the reified entity type. Eg 'internship [i] is student [s] at company [c] and ...'.)
(Correctly speaking there are entity types vs relationships and entities vs relationship instances. But the assignment talks of relationship "types".)
Re E-RM see this answer and this one. Also the E-RM wiki page section 'Entity–relationship modeling'. (Which correctly mentions misinterpretations of Chen's E-RM & E-RDs by some related modeling and diagramming methods and tools and even some presentations of E-RM itself. But the 'Overview' is nonsense.)
Re E-RM problems see this.

Resources