Django GenereicForeignKey v/s custom manual fields performance/optimization
<p>I'm trying to build a typical social networking site. there are two types of objects mainly.</p>

<ol>
<li>photo </li>
<li>status</li>
</ol>

<p>a user can like photo and status.  (Note that these two are mutually exclusive)
means, We have two table (1) for Image only and other for status only.</p>

<p>now when a user likes an object(it could be a photo or status) how should I store that info.</p>

<p>I want to design a efficient SQL schema for this.
Currently I'm using Genericforeignkey(GFK) </p>

<pre><code>class LikedObject(models.Model):
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey('content_type', 'object_id')
</code></pre>

<p>but yesterday I thought if I can do this without using GFK efficiently?</p>

<pre><code>class LikedObject(models.Model):

    OBJECT_TYPE = (
        ('status', 'Status'),
        ('image', 'Image/Photo'),
    )

    user = models.ForeignKey(User, related_name="liked_objects")
    obj_id = models.PositiveIntegerField()
    obj_type = models.CharField(max_length=63, choices=OBJECT_TYPE)
</code></pre>

<p>the only difference I can understand is that I have to make two queries if I want to get all liked_status of a particular user</p>

<pre><code>status_ids = LikedObject.objects.filter(user=user_obj, obj_type='status').values_list('object_id', flat=True)
status_objs = Status.objects.filter(id__in=status_ids)
</code></pre>

<p>Am I correct? so What would be the best approach in terms of easy querying/inserting or performance, etc.</p>