2019-06-29
|~2 min read
|235 words
Yesterday, in talking about Postgres and Subqueries I was trying to represent a relationship between tables. I knew intuitively what I was trying to communicate, but wasn’t sure about the syntax.
Digging into I found Lucidchart1 had put together a pretty useful cheatsheet on entity-relationship diagrams which the information I was looking for (image credit to Lucidchart).
Interestingly, I think one of the examples they have in the post doesn’t make a lot of sense given that information.
In this example, the BankId
is the primary key (which means it’s not nullable). As a result, the way I’m reading the above ERD is that we can have zero or one BankId
associated with zero too many cars’ FinancedBy
.
How you can have zero is beyond me, however, at least I now know why it’s confusing because what the lines mean is no longer a mystery!
Update Thinking more about this, the zero does not refer whether or not there’s a
BankID
at all, but whether or not thatBankID
is associated with anyCar
objects. Said another way, you can have a bank that has financed zero cars. That’s an appropriate relationship in this ERD. On the other hand.
I also found a resource compiled by Oracle that is similarly useful with some additional examples.
Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!