powerdesigner如何创建外键

先创建两个entity

因为是多个t主题(topic)对应一个作者(author)

所以topic要有个外键author_id参照author的id

那么双击topic,创建一个column author_id 并且在M上选对勾:意思是这个外键必须有值(帖子肯定是要有个作者发啊,不能是null)

Mandatory

When selected, indicates a column that must be assigned a not null value

 

然后点击reference,并连上2个entity

双击连接线,parent table即是author,而child table 是topic

Parent table

Specifies the parent table of the reference. This table contains the primary key, or alternate key, linked by the reference.

Child table

Specifies the child table of the reference. This table contains the foreign key linked by the reference

然后在joins里面把parent key 选为none,在指定外键列child table column

得到

如果praent key选为

那么你的外键就会是topic 主键加上author_id外键

你可能感兴趣的:(powerdesigner)