Can the same column have primary key & foreign key constraint to another column

后端 未结 3 1075
执笔经年
执笔经年 2021-01-07 19:13

Can the same column have primary key & foreign key constraint to another column?

Table1: ID - Primary column, foreign key constraint for Table2 ID
Table2         


        
3条回答
  •  佛祖请我去吃肉
    2021-01-07 19:59

    Yes, it can.

    No, it won't.

    P.S. But you'll not be able to delete table2 data without deleting corresponding table1 rows obviously.

    P.P.S. I've implemented such structure in Postgres, but it must be similar for MySQL.

提交回复
热议问题