还是国外的正规,都在作DJANGO ORM的解藕化工作了。
外键不用,多对多,一对多,不用。
参考URL:
http://scottlobdell.me/2015/01/sql-database-best-practices-django-orm/
==========这个网站有很多DJANGO干货哟=============
The last example really encapsulates most of what I’ve written about.
- There’s an index for one side of the many to many table based on the query patterns of our use case.
- There’s no foreign key (I used an integer instead of a foreign key).
- There’s an abstraction layer for the use case.
- Database queries are made one table at a time with no table joins or dependent sub-queries.
- I’m casting QuerySets to lists as soon as I know I want to fetch data from the database.
- The “gotchas” that you might experience with Django are impossible to stumble upon for another programmer that’s using the new class’s API.