Can someone please tell me where I went wrong for an exercise submission

database-designdatabase-diagramserd

I recently submitted an assignment in a group for our databases class and we lost points on one of the exercises and the correction is unclear. If someone could examine the question, the submission and the grader's comment for me and tell us what we did wrong I would greatly appreciate it.

Question:

Given a set of cities in some country, we would like to design an ER-diagram which records the distance between every pair of cities. Assume the attributes for each city is its name and its population with the name being unique, i.e., no 2 cities have the same name. Form an ER-diagram to model this application.

Our submission:

In this example, we see that there is a city entity set, and a country entity set. The city set has attributes of Cname, to distinguish between unique cities, and population. The relationship between country and city is “Located In” and is an M-1 relationship, because there are many cities in only one country. Additionally, city has a recursive relationship that measures the distance between a city and another unique city. The relationship between cities is “Distance” and has a M-1 relationship as well, because the distance from a single city can be compared to many other cities in a country.

enter image description here

The comment:
"Use distance as a relation."

Any help is appreciated. Thank you!

Best Answer

Makes little sense to me. Can you not approach your lecturer/examiner and request further feedback?

Personally I wouldn't be storing distances - store the coordinates and do the calculation on the fly. If you have 100 cities, then you have to store 99 distances with each city - not very pretty.

An example with MySqL is here. If MySQL has this, I'd be fairly sure that all the other major vendors support this functionality. And they do! Found this also which you may find this helpful. You didn't mention the name of your RDBMS but you should always do so.

Take the tour, check out the help centre and the "Help us to help you" blog. p.s welcome to the forums!