drawdb icon indicating copy to clipboard operation
drawdb copied to clipboard

Cardinality backwards

Open mflagler opened this issue 1 year ago • 1 comments

Maybe I've always thought of it wrong, but wouldn't the cardinality of one to many indicate that I have 1 record in the table with the primary key to many records in the table with the foreign key? This is currently backwards, and I have to specify this as many to one, which seems backwards to me. Am I the only one thinking this?

mflagler avatar Jul 25 '24 18:07 mflagler

The program doesn't have any 'real' understanding of what the primary and foreign tables are, so the 1 and n labels are assigned first to the 'start table' and then to the 'end table'.

image

For example, here, since postId references posts(id), the relationship gets created from postId to id. Comments becomes the 'start table' and posts becomes the 'end table'. So when you pick many-to-one, the comments side gets n and posts - 1.

At the end of the day, one-to-many and many-to-one are the same thing depending on which table you consider first.

1ilit avatar Jul 28 '24 13:07 1ilit

Feel free to reopen the issue if you still have questions

1ilit avatar Aug 06 '24 15:08 1ilit