Monday, 11 February 2019

Best way to pair 2 rows together in MySQL?

So I am working with a bioinformatics database. I have a table for cell plates and there are columns like cell_line, magnification, timepoint, date_recorded etc. Also there's another table for images which are associated with each cell plate with a foreign key.The issue is that each cell plate needs to be paired with another cell plate, and the pictures from both the cell plates together form one complete dataset entry. (In a way, 2 cell plates constitute one complete dataset)For example, if two cell plates have the same cell_line, magnification, timepoint, and date_recorded, they belong to the same pair. Ideally I want to be able to have the cell plates paired together somehow in my db so I can retrieve all the images of a cell-plate pair, and get one complete dataset.I was thinking of different approaches as following:Have a separate table called paired_plates and have a column inside for paired plates indexed, and assign a value or id in the foreign key column in the cell plate table. So 2 cell plates that have for example pair_plate id 1 belong to the same pair. And I would hopefully be able to retrieve all the images associated with it.Have another column inside cell plates table for pairing cell plates together.Maybe I dont even need to pair them, just query the specified conditions and the result should give me the paired plates.Any other approaches to this maybe?​

Submitted February 12, 2019 at 05:26AM by yungspartan0082

No comments:

Post a Comment