Forum OpenACS Q&A: Re: One to Many Relationship

Posted by Jarkko Laine on
Hi Nathan,

One-to-many (as well as many-to-many and one-to-one) relationship is a key concept of relational database design, so PostgreSQL like any other RDBMS can certainly handle those. You might want to read some intro (e.g. to this topic to get a deeper understanding of what they mean.

What Peter suggests creates actually a many-to-many relationship, so like Tom says, you don't need a mapping table for your task.

Tom's post explains very well how an one-to-many relationship is made in SQL, so I'll just point out that you don't use a list in table1's column but rather specify the relationship in every row of table2. One basic concept of relational model is that every attribute is atomic -- i.e. you only have one value stored in one column of one row. That means no lists as column values.