When creating PK/FK relationships between tables in the Retool database, how can you specify cardinality and ordinality? I.e. if you want to allow one-to-many or many-to-many relationships.
With many-to-many relationships in Postgres, you'd typically want to implement a linking table. Say you have
topics, and any given
newsArticle may have several topics. You'd then implement a
newsArticles_topics table with a structure of
topicId, and then for each topic you associate with the specific article, there's one row in
Does this make sense :-)?
Yes, that does make sense.
Suppose I also have a
news_category and I would want to force a
newsArticle to have exactly 1
news_category, how would I do that?
news_category relationship is many-to-one you might try adding a foreign key to the
newsArticle table that links to
So you'd handle many-to-one as a fk relationship and the many-to-many relationship with a separate table as @jonathanbredo mentioned. Does that seem like it could work?
Thanks Kabirdas! I started studying PostgreSQL to avoid having to ask such basic questions in the future.