title: which table structure would be better?
body: <p>I cant decide which way is better to create a <strong>key/value</strong> <strong>Tag</strong> model in <strong>Django</strong>,</p>
  
  <pre><code>class Tag(models.Model):
      tag = models.CharField(max_length=35, unique=True)
      description = models.CharField(max_length=250, null=True)
      is_key = models.BooleanField(default=False)
      parent = models.ForeignKey("self", blank=True, related_name="key")
  </code></pre>
  
  <p>or</p>
  
  <pre><code>class TagKey(models.Model):
      key = models.CharField(max_length=35, unique=True)
      description = models.CharField(max_length=250, null=True)    
  
  class TagValue(models.Model):
      value = models.CharField(max_length=35, unique=True)
      description = models.CharField(max_length=250, null=True)
      port = models.PositiveIntegerField(default=0)
      key = models.ForeignKey(TagKey)
  </code></pre>
  
  <p>All I intent to do is create a key:value based tag model which I can use to tag my applications.<br></p>
  
  <p>Explanation: What I am doing in <strong>Tag</strong> class is that I am giving a self relation to itself when I will be adding a value tag, but if I am adding a key type Tag then I wont be populating the <strong>parent</strong> field. <br><br>
  P.S I have to use my own tag model so please don't suggest third party <strong>Django</strong> tag app</p>