eralchemy
eralchemy copied to clipboard
relation cardinality labels drawn in reverse position
Example model:
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from eralchemy import render_er
Base = declarative_base()
class Person(Base):
__tablename__ = 'person'
name = Column(String(255), primary_key=True)
height = Column(Integer)
weight = Column(Integer)
birth_location_id = Column(ForeignKey('location.id'))
location = relationship('Location')
class Location(Base):
__tablename__ = 'location'
id = Column(Integer, primary_key=True)
city = Column(String(255))
state = Column(String(255))
country = Column(String(255))
The way I read the source code:
- Person has at most one birth location
- Multiple persons may have the same birth location
Here's the respective diagram generated by eralchemy
The way I read the diagram:
-
0
toN
Locations relate to0
or1
Persons
It seems to me that relation representation in the diagram conveys the exact opposite meaning than it should.
Please also note that eralchemy's cardinality label style most closely resembles the UML specification, but label positioning doesn't. This adds another layer of confusion when interpreting eralchemy's diagrams.
Solution proposal:
Swap cardinality labels' positions or at least add an option (to CLI and render_er
) so that the user can chose for themself.
Got the same confusion today, indeed the diagram of the example suffers from this issue (see users/comments or users/posts for example)
@Alexis-benoist please, merge PR. It's very desirable fix.