Saturday, April 6, 2013

need help designing models

Consider a university college.
1. College has name, uid, website
2. Each college has a many departments - Each department has name, uid.
3. Each batch in a department has name, and ratings.

from django.db import models

class College(models.Model):
name = models.CharField(max_length=200)
uid = models.CharField(max_length=10, primary_key=True)
website = models.URLField()

def __unicode__(self):
return self.name

class Department(models.Model):
name = models.CharField(max_length=200)
uid = models.CharField(max_length=10)
college = models.ForeignKey(College)

def __unicode__(self):
return self.name

class Batch(models.Model):
name = models.IntegerField(max_length=100)
department = models.ForeignKey(Department)
college = models.ForeignKey(College)
rating = models.IntegerField(default=0)

def __unicode__(self):
return self.name

Would you suggest any better design ? (actually, I never formally read DB)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate