Last active
August 29, 2015 14:12
-
-
Save liddiard/f193fd33394b26243d3d to your computer and use it in GitHub Desktop.
Mock database design for Twidder, a social networking app that has nothing at all to do with a social networking app of a similar name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class User(models.Model): | |
# Django's auth framework provides its own very | |
# capable user model, but we'll make our own | |
# assuming English/Western-style names – | |
# first name/last name distinction doesn't apply in all cultures | |
first_name = models.CharField(max_length=64) | |
last_name = models.CharField(max_length=64) | |
email = models.EmailField() | |
username = models.CharField(max_length=20) | |
password = models.PasswordField() # this isn't actually a thing but | |
# we're going to pretend it is | |
following = models.ManyToManyField('self') | |
# Django automatically creates an intermediary table for us to | |
# handle many-to-many relations | |
class Message(models.Model): | |
user = models.ForeignKey('User') | |
text = models.CharField(max_length=120) | |
created = models.DateTimeField(auto_now_add=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment