> For the complete documentation index, see [llms.txt](https://petercheng7788.gitbook.io/developer-note/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://petercheng7788.gitbook.io/developer-note/backend/database/sql/relationship.md).

# Relationship

## One-to-one relationship

![](/files/-MGt6Emz__UiWRb5YUev)

* Table A and B is in one to one relationship ,actually the column of table A and B can be combined into one table,  since product feature is optional, so we can separate into 2 tables.

## One-to-many relationship

![](/files/-MGt6MH0JbshwcKu29qK)

* Table A and B is one-to-many relationship,  table A is one , table B is many, as we see that different rows of table B can have the same foreign key referencing to table A.&#x20;

## Many-to-many relationship

![](/files/-MGt723BevMPRGPOW3KN)

* Table A and C is many-to-many relationship, same product can exist in different places and same place can contain different products, we cannot directly link table A and C directly, we need to setup a bridge which is table B. Table A and table B is one-to-many relationship. Table C and B is also a one-to-many relationship.
