title: Can MySQL constrain based on a NULL value combined with an id?
body: <p>I use django-mptt to make a tree structure on a model in a web app.</p>
  
  <p>Unfortunately - once in a while I will get duplicate root nodes in a tree.</p>
  
  <p>These will have NULL as parent_id, and the same tree_id, like this:</p>
  
  <pre><code>+--------+-----------+---------+
  | id     | parent_id | tree_id |
  +--------+-----------+---------+
  | 159092 |      NULL |   52098 | 
  | 159093 |      NULL |   52098 | 
  +--------+-----------+---------+
  </code></pre>
  
  <p>Is there any way to stop this at the database level?<br>
  Can I make a constraint in MySQL to avoid getting two or more items with NULL as parent_id and the same tree_id?</p>
  
  <p>Model from models.py with irrelevant fields removed:</p>
  
  <pre><code>class Message(MPTTModel):
      # Threaded messages
      text = textmodels.TextField()
  </code></pre>