如何在ER图中显示多个主键?

问题描述 投票:0回答:1

我在 Book 实体中有以下字段:

public class Book {

    private int id;

    @NaturalId
    @Column(length = 26, nullable = false, unique = true)
    private String isbn;

    private String name;

    // other fields
}

我使用了带有 PK、FK 和 PK + FK(复合键)的 ER 图,但是我没有使用也没有找到任何示例用法来说明当我有一个 PK 和另一个 PK / 业务键 / 唯一键(isbn 字段)时的情况).

那么,如何显示isbn的key类型呢?我认为它不能是 PK,因为一个实体可以有一个 PK。它不是 FK。那么Er Diagrams中有BK(business key)的表示法吗?

java c# entity entity-relationship erd
1个回答
0
投票

如果我对你的问题理解正确,你需要将 ISBN 列定义为唯一的,所以它有一个唯一的索引:

@Entity
public class Book {

    @Id
    private int id;

    @Column(unique=true)
    private String isbn;

    private String name;

    // other fields
}
© www.soinside.com 2019 - 2024. All rights reserved.