如何设计具有多个DTO的数据库表

我有两个DTOs

RedCatDTO {
 color: string,someSpecialAttribute: string
}

BlueCatDTO {
 color: string,someSpecialAttribute: string
}

如何设计数据库表并存储这两个DTOs

k13122603 回答:如何设计具有多个DTO的数据库表

SQL

CREATE TABLE CAT {
 color varchar(24),attribute varchar(24),}

JAVA

public class Cat{
  String color;
  String attribute;
}
public class BlueCat extends Cat{
  String color = blue;
}

或者您可以说

Cat blueCat = new Cat();
blueCat.setColor("blue");

请注意,这是粗略的代码,因此您需要研究如何创建表等。

本文链接:https://www.f2er.com/3161018.html

大家都在问