Answer the question
In order to leave comments, you need to log in
What are mysql table relationships for?
I am making a REST API on node + express + sequelize. I just can't figure out how to apply table links and whether it's necessary at all.
For example, there are two tables:
"Categories"
id
name
"Posts"
id
category
title
content
Why do I need links ( Post.belongsTo(Category); ), if I myself can create a category field in the posts table and pass the category id when adding a post.
Or I do not understand something and do not think correctly?
And what are connections for?
Answer the question
In order to leave comments, you need to log in
With connections
sequelize does this instead of you. Constraints
in relational databases ensure the reliability and integrity of the data (with them, by mistake, it will not be possible to add a post to a non-existent category or delete categories leaving lost posts)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question