我有一堂运动和训练课。我想在每次培训中进行一组练习。我的问题是——如何在数据库和 Java 中表示?
我想到的是根据表training_id中的外键在特定训练中添加一个练习exercise。但我想将每个练习存储在一组训练中,或者只列出训练课程的一个领域——我认为这是这样做的好方法,但我可能是错的。
@Entity
@Table(name = "exercise")
public class Exercise {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "exercise_id")
private int id;
@Column(name = "exercise_name")
private String name;
@Column(name = "weight")
private double weight;
@Column(name = "series")
private int series;
@Column(name = "training_id")
private int trainingId;
@Table(name = "training")
public class Training {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "training_id")
private int id;
@Column(name = "training_name")
private String trainingName;
@Column(name = "date")
private Date date;
private Set<Exercise> exercises;
也许我不明白它的概念。谁能告诉我正确的方法吗?
慕无忌1623718
相关分类