简体   繁体   中英

Joining two database tables with django

I am doing several measurements of voltage, resistance, frequency, etc. of a device. I want to have a table for each measurement as well as a main table with the serial number of the device and boolean values if it has passed the tests.

I planned to have the structure similar to this:

create table volt(serial char(20),v1 float(10),v2 float(10)....)
create table resistance(serial char(20),r1 float(10),r2 float(10)....)
create table device(serial char(20),freq boolean(),tx boolean....)

I admit to not having a lot of experience with django and I have no idea how to create a model like this. I tried making seperate classes and using foreignKey, but for that I'd have to create the resistance and volt measurements first.

It is possible to store the measurement values as comma seperated strings as well, but I'd rather have it in a proper database.

Any hints?

您的VoltageResistance等模型应具有Device模型的ForeignKey

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