簡體   English   中英

sql關系表

[英]sql relationships table

在創建表之間的關系時只想問一個問題。

如果我想在 tableA 和 tableB 之間創建關系。 我可以看到有不同的方法來做到這一點。 只想了解這些方式的優缺點。

1. 另一個表將 tableA 和 tableB 鏈接在一起

Create Table tableA (
tableA_id int
)

Create Table tableB(
tableB_id int
)

Create table tableA_B(
tableA_id int,
tableB_id int
)

2.在tableA中添加tableB_id將它們鏈接在一起

Create Table tableA (
tableA_id int,
tableB_id int
)

Create Table tableB(
tableB_id int
)

抱歉我的英語不好:(

希望我解釋得很好。

在 1 中,您創建了第三個表,因為 A 和 B 具有多對多關系。 2中,A表和B表是一對多的關系。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM