mysql - schema database design for Q&A website?
过去多啦不再A梦
过去多啦不再A梦 2017-06-30 09:53:50
0
1
906

Beginnerdjango, prepare to practice imitating a simplifiedsegfmentfaultwebsite. Now I have a fewquestions.

class Answer(models.Model): id = models.IntegerField(primary_key=True) user_id = models.PositiveIntegerField(verbose_name='用户ID') vote = models.IntegerField(verbose_name='得票') data = models.TextField(verbose_name='数据', max_length=4096 * 10) post_time = models.DateTimeField(verbose_name='创建时间', default=datetime.datetime.now) mod_time = models.DateTimeField(verbose_name='修改时间') class Meta: verbose_name = '用户回答' class Question(models.Model): Q_CHOICES = ( ('0', u'Show'), ('1', u'Hide'), ('2', u'Closed'), ) BOOL_CHOICES = ( ('0', u'False'), ('1', u'True'), ) id = models.IntegerField(primary_key=True) name = models.CharField(verbose_name='名称', max_length=128) status = models.CharField(verbose_name='状态', max_length=1, choices=Q_CHOICES) type = models.SmallIntegerField(verbose_name='类别') post_time = models.DateTimeField(verbose_name='创建时间', default=datetime.datetime.now) mod_time = models.DateTimeField(verbose_name='修改时间') vote = models.IntegerField(verbose_name='得票') data = models.TextField(verbose_name='数据', max_length=4096 * 10) user_id = models.PositiveIntegerField(verbose_name='用户ID') view_num = models.PositiveIntegerField(verbose_name='浏览数') class Meta: verbose_name = '问题列表'
  1. Now in the database area, theanti-paradigmdatabase design is recommended. Isforeign keysuitable for this kind of Q&A website?

  2. What fields are missing from my table? These are the only ones I can think of. Please give me a rough analysis.

Question form

Answer form

Comment form

过去多啦不再A梦
过去多啦不再A梦

reply all (1)
学霸

In terms of scale, foreign keys are not suitable for large amounts of data, but can be used for small ones; for applications where security and reliability are important, foreign keys should be used, otherwise they may not be used. Detailed analysis of specific situations

The specific missing fields are determined by the business

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!