views:

33

answers:

3

Hello guyz, I am new to ERD and stuff.Earlier i was drawing an erd that issued me some problems. the name of two entities in focus is "Bus" and "Passenger".What shall be the relationship between them. I think it should be many to many since one passenger can travel in many buses and a bus can give ride to many passengers.But one of my friend insisted that its a one-to-many relationship(A bus can have many passengers but a passenger can travel in only one bus).Plz let me know what's right.

Also , whats the relationship between a class,students.

Any help is appreciated.

+2  A: 

It depends on what you're trying to model.

You're correct that in general, a passenger can travel in many buses and a bus gives rides to many passengers. But do you really want to model a many to many relationship? It depends on what data you're tying to gather.

If it is, then you need 3 tables. A passenger table, a bus table, and a ride table. The passenger table has a 1 to many relationship with the ride table. The bus table has a 1 to many relationship with the ride table.

The ride table key is logically a combination of the passenger table key and the bus table key. The elements of the ride table could include the date and time of boarding, the boarding station, the date and time of arrival, and the arrival station.

The relationship between classes and students is also many to many. A student takes 1 to 8 classes, and a class contains 1 to 30 students. In this relationship, you have limits, which I defined as 8 and 30 respectively. The actual limits would depend on your application.

Gilbert Le Blanc
Thanks for the help.Really appreciate it.In my second question, a class means a grade.Like when we are in school, we are in grade 1,an year later we reach grade 2 and so on.So the question is that a class can contain 1.. many students, but can this be a many to many relationship. Like at one time, i was in grade 1 but then i progressed to grade 2 and so on.So, in this sense can this be a many to many relationship.
Mobi
A: 

Thanks for the help.Really appreciate it.In my second question, a class means a grade.Like when we are in school, we are in grade 1,an year later we reach grade 2 and so on.So the question is that a class can contain 1.. many students, but can this be a many to many relationship. Like at one time, i was in grade 1 but then i progressed to grade 2 and so on.So, in this sense can this be a many to many relationship.

Mobi
Ok. There are many students in a grade. A student is in one grade. A one to many relationship.
Gilbert Le Blanc
If you want to keep track of a student's progress through the grades, then yes, student and grade is a many to many relationship.
Gilbert Le Blanc
A: 

thnks buddy.U Rock

Mobi