简体   繁体   中英

Do I need a third table in my schema

Scenario: Each "order" can only have one "import file" . So I created a table with its main columns as *order_code* and *file_code* (Order_File Table) Also Each "order" can have multiple "Genes" . So I created another table with its main columns as order_code and gene_code . ( Order_Gene table)

So now in front-end side, user picks an "order" from a combobox, We show the import file of that order and the lists of genes for that order.

I wanted to know your opinion about this schema design and if I am designing it wrong or it is correct? Thanks.

That sounds right if I'm understanding you correctly. The import file is an attribute of an order, and the Genes table is on the many side of a one-to-many relationship allowing many genes to be associated with one order, but each gene can only be associated with one order.

If you want to associate many genes with many orders (ie 'reuse' records in the gene table for multiple orders) you'll need to create a 'link table' with an order_code and a gene_code column, and create a record there for each link or association between the two tables.

如果每个订单代码都是唯一的,那么您正在讨论的设计将起作用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM