Who should establish the relationship? The Entity or the Data Mapper?

There are four classes:

StudentBase, CourseBase and StudentDataMapper, CourseDataMapper

An Student object can have a relationship with an Course object. One Student can have many courses. One course can be visited by many students.

In the ER diagram, a Student entity has an attribute called "courses", but a course does not know anything about his students. A course has no Attribute called "students" in return.

Which of these classes should perform the creation of the relationship?

EDIT: This is the System Layer! In the Business Logic Layer, the developer subclasses StudentBase and CourseBase to create a Student class and an Course class. The developer who creates these classes will not see any of that code, except for his own business logic code.

Answers


Neither.

First, the ERD should change; what you've described is a many-to-many relationship (a course can have many students and a student many courses). So, the student shouldn't have a courses attribute but, instead, there should be a student-course entity.

Then there should be a StudentCourseDataMapper class that does what you're asking (maintaining relationships) and both StudentDataMapper and CourseDataMapper should be aware of and use it.


Need Your Help

How to manipulate pom.xml while creating project via archetype

maven-2

I'm making an archetype via the goal create-from-project and a propertyFile for webservice projets which using jaxws. Therefore I have to enter the service endpoint implementation into the configur...

Grabbing data from database based on dropdownlist selection

c# asp.net asp.net-mvc asp.net-mvc-4

I am porting a windows desktop application to an ASP.NET MVC application. Currently I have a table in the database that stores a bunch of race events and I want to display the list of registrants for

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.