Started doing a project on Django. The following data is available in JSON (I cite part of the structure, the rest is repeated):
[{"name": "Hydrogen", "atomic_number": 1, "symbol": "H", "thermal": {"absolute_boiling_point": { "value": 234, "unit": "K"}, "heat_of_vaporization": { "value": {"p": 4, "M": 0.452, "n": 10}, "unit": "kJ/mol"}}}] For clarity:
It can be seen that the structure is quite complex and repeatedly nested.
The element has properties without a group (type, Name, symbol, atomic_number, which is about ten and they are common to all elements) and property groups (there are several dozen groups, each of which also includes several dozen properties).
As you can see, the value of the properties can be represented by a string, decimal number and engineering record (for which three numbers are used - mantissa, base, degree)
There was a problem - I can not describe this structure through the relational database of the project (postgresql), I can not establish links.
Will a relational database suit me? Or should you look for a noSQL solution? Do I choose the right tools for the project?
Created models for item
class Element(models.Model): class Meta: verbose_name = 'Element' verbose_name_plural = 'Elements' name = models.CharField(verbose_name="Name", max_length=255, blank=True, null=True) symbol = models.CharField(verbose_name="Symbol", max_length=255, blank=True, null=True) Various recording forms
class ScientificNotation(models.Model): class Meta: verbose_name = 'Scientific Notation' significand = models.FloatField(verbose_name="Significand", blank=True, null=True) base = models.IntegerField(verbose_name="Base", blank=True, null=True) exponent = models.IntegerField(verbose_name="Exponent", blank=True, null=True) unit = models.CharField(verbose_name="Unit", max_length=255, blank=True, null=True) class DecimalNotation(models.Model): class Meta: verbose_name = 'Decimal Notation' value = models.FloatField(verbose_name="Value", blank=True, null=True) unit = models.CharField(verbose_name="Unit", max_length=255, blank=True, null=True) Property groups With this model, and there is a problem.
class ThermalProperties(models.Model): class Meta: verbose_name = 'Thermal properties' verbose_name_plural = 'Thermal properties' element = OneToOneField(Element) melting_point = ForeignKey(ScientificNotation) boiling_point = ForeignKey(ScientificNotation) heat_of_vaporization = ForeignKey(DecimalNotation) I can not refer to the same model (in a specific example, ScientificNotation)
ERRORS: table.ThermalProperties.boiling_point: (fields.E304) Reverse accessor for 'ThermalProperties.boiling_point' clashes with reverse accessor for 'ThermalProperties.melting_point'. HINT: Add or change a related_name argument to the definition for 'ThermalProperties.boiling_point' or 'ThermalProperties.melting_point'. And I will duplicate the question here if someone has read it. Will a relational database suit me? Do I choose the right tools for the project?
