Not sure the best way to describe the problem. I have 2 contacts and a table attribute. The contact table has 1 entry per person, and the attribute table has 0, 1, or many entries per person. They are currently connected to a βfakeβ foreign key, which is not really a foreign key. If I need to add a foreign key, I will not deal with old data, and initially there was no foreign key. Thus, the tables are laid out as follows:
contact:
class contact(models.Model):
contactId = models.AutoField(primary_key=True, db_column='contactId')
firstName = models.CharField(max_length=255, null=True, db_column='firstName')
middleName = models.CharField(max_length=255, null=True, db_column='middleName')
lastName = models.CharField(max_length=255, null=True, db_column='lastName')
attribute:
class attribute(models.Model):
attributeId = models.AutoField(primary_key=True, db_column='attributeId')
contactId = models.IntegerField(db_index=True, null=True, db_column='contactId')
attributeValue = models.TextField(null=True, db_column='attributeValue')
, Django . , , - , XML- :
<contacts>
<contact>
<contactId></contactId>
<firstName></firstName>
<lastName></lastName>
<attributes>
<attribute>
<attributeId></attributeId>
<attributeValue></attributeValue>
</attribute>
</attributes>
</contact>
</contacts>
, , .
, . , , . , , , django/python, .
, , .