zoukankan      html  css  js  c++  java
  • 数据库设计

     1.属性形同的归一张表
          连表有性能消耗
            (1):连表设计:
                    方式一:
                        class UserType(models.Model):
                            """
                            用户类型表,个数经常变动
                            """
                            title = models.CharField(max_length=32)

                        class UserInfo(models.Model):
                            """
                            用户表:讲师和班主任
                            """
                            username = models.CharField(max_length=32)
                            password = models.CharField(max_length=64)
                            email = models.CharField(max_length=32)
                            ut = models.ForeignKey(to="UserType")
                   方式二:
                    - choices
                            # class UserInfo(models.Model):
                            #     """
                            #     用户表
                            #     """
                            #     username = models.CharField(max_length=32)
                            #     password = models.CharField(max_length=64)
                            #     email = models.CharField(max_length=32)
                            #
                            #     user_type_choices = (
                            #         (1, '班主任'),
                            #         (2, '讲师'),
                            #     )
                            #
                            #     user_type_id = models.IntegerField(choices=user_type_choices)

  • 相关阅读:
    Codeforces Round #644 (Div. 3)(A~G)
    【】BZOJ3687: 简单题(dp+bitset)
    [LeetCode] 275. H-Index II
    [LeetCode] 1028. Recover a Tree From Preorder Traversal
    [LeetCode] 1014. Best Sightseeing Pair
    [LeetCode] 468. Validate IP Address
    [LeetCode] 701. Insert into a Binary Search Tree
    [LeetCode] 658. Find K Closest Elements
    [LeetCode] 787. Cheapest Flights Within K Stops
    [LeetCode] 1300. Sum of Mutated Array Closest to Target
  • 原文地址:https://www.cnblogs.com/mengqingjian/p/7810926.html
Copyright © 2011-2022 走看看