4 ms·
Beyond Foreign Keys
- jpollock 3y agoI'm confused by the change from a schema view of the world into an API view of the world. Isn't it still implemented as a foreign key?
- tie-in 3y agoNo foreign keys are used. A separate database table is used to track relationships.
- readthenotes1 3y agoI wonder how easy this will be to debug once it's used in a non trivial production environment. All the other "we use thing relates to thing because structured data slows us down" I used were nightmares.
- jacknews 3y agoSo the relations must be stored somewhere. I'm guessing a join table that includes the table names of each record, ie a 'polymorphic' join table?
- tie-in 3y agoYou've guessed it right :) An entry in the relationship table looks something like this: { "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" }