我正在开发一个应该生成校准证书的应用程序。 我们有10种类型的证书。
证书编号应自动生成。 证书应保存在数据库中(MySQL) 编号应该是顺序的。我只想知道编号证书和将数据保存在数据库中的最佳机制。
顺便说一下,我正在使用休眠。 谢谢,
I'm working on an application that is supposed to be generating calibration certificates. We have like 10 types of certificates.
Certificates number should be auto generated. Certificates should be saved in the database (MySQL) numbering should be sequential.I just want to know the best mechanism for numbering the certificates and persisting the data in the database.
I'm using hibernate by the way. Thanks,
最满意答案
我想你想要一个自动递增的字段,就像@ bart2puck指出的那样。 但是,您还可以根据该数字添加自定义“公司”和“证书”字段。 CONCAT(id,' - ',Company,' - ',Type)类型。 所以,记录可能看起来像这样
ID (auto) Company CertificateType CertificateId 345 22 5601 22-5601-345添加索引时,请创建它(CertificateId,CertificateType,ID)
I think you want an auto incremented field as @bart2puck pointed out. but, you could also add a custom 'company' and 'certificate' field based upon that number. CONCAT(id,'-',Company,'-',Type) type. So, a record may look like this
ID (auto) Company CertificateType CertificateId 345 22 5601 22-5601-345When you add your index, create it upon (CertificateId,CertificateType,ID)
更多推荐
发布评论