DEV Community

Discussion on: SQL tips for beginners; what I learned after 10+ years of occasionally writing queries and schemas as a web dev

Collapse
 
nstvnsn profile image
Nathan Stevenson • Edited

In regards to technical tables when using models with an ORM, do you mean helper tables? Like if there could be a relationship between 2 entities of the same model (i.e. a forum or chat app, 2 users having a friend relationship). Or perhaps other tables that contain additional details related to a particular model?

If not, could you elaborate on that a bit, or suggest a source I should look into myself?

A good read. I'm currently working on a project where I am creating models and have implemented one of the examples I mentioned above (a friends helper table with a primary key made up of the foreign keys from each user, and a date created field to represent friends in a chat app).

I am constantly amazed by how much I have learned, in contrast with how much I'll never be able to learn. There's just so many facets to development and related disciplines.

Collapse
 
rap2hpoutre profile image
Raphaël Huchet

Thank you for your feedback! 🙏

In regards to technical tables when using models with an ORM, do you mean helper tables? Like if there could be a relationship between 2 entities of the same model (i.e. a forum or chat app, 2 users having a friend relationship). Or perhaps other tables that contain additional details related to a particular model?

That's it, I mean both!

The most obvious case is pivot tables (n..m relationship), i.e: users have n groups, groups contain m users, then you need a group_user table (a.k.a a pivot table). This kind of table represents a relation between two models, not a model itself.

There can also be 1..1 tables (a subset of properties of a model split in another table). Or shared properties between two models that does not need to be represented themselves (maybe addresses for users and companies, when address is not considered a model in application, just a property).

I am constantly amazed by how much I have learned, in contrast with how much I'll never be able to learn. There's just so many facets to development and related disciplines.

Thanks for sharing! That's dizzy and that's what I love in dev! I still consider I'm a beginner (let's say intermediate-beginner) in SQL and I'm always amazed by thing I discover via other peoples' work.