this post was submitted on 11 Apr 2024
15 points (89.5% liked)

Programming

16947 readers
555 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
15
Beyond Foreign Keys (lackofimagination.org)
submitted 4 months ago* (last edited 4 months ago) by Aijan to c/programming
top 9 comments
sorted by: hot top controversial new old
[–] [email protected] 9 points 4 months ago (1 children)

So... a polymorphic many-to-many join table?

[–] Aijan 3 points 4 months ago (2 children)

Yes, that's correct. Here's how an entry in the join table looks like:

{
  "id": 6,
  "sourceComp": "user",
  "sourceId": 2,
  "targetComp": "post",
  "targetId": 3,
  "type": "author",
  "createdAt": "2024-03-28T13:28:59.175Z",
  "updatedAt": "2024-03-28T13:28:59.175Z"
}
[–] [email protected] 6 points 4 months ago* (last edited 4 months ago) (1 children)

Fine for prototyping, but adds a scaling tech debt "time bomb" for a live system. Those associations had better be really sparse.

[–] Aijan 2 points 4 months ago

There's certainly the danger of creating too many ad-hoc or sparse relationships, which can cause issues. That said, when used for supplementing foreign keys, Tie-in can be a useful tool in a production system as well.

[–] [email protected] 4 points 4 months ago (2 children)

Don't you want a graph database at this point?

[–] Aijan 3 points 4 months ago* (last edited 4 months ago)

That idea crossed my mind too, but you can’t really use the full capabilities of SQL in graph databases, and that’s a deal breaker for me.

[–] [email protected] 2 points 4 months ago

i was thinking the same thing

[–] [email protected] 7 points 4 months ago (1 children)

NoSQL has been a thing since before there was SQL.

[–] Aijan 3 points 4 months ago

AFAIK, no NoSQL database fully supports SQL, and only some offer support for transactions and joins. The idea here is to augment a relational database by adding capabilities for dynamic relationships.