- Django Design Patterns and Best Practices
- Arun Ravindran
- 313字
- 2021-06-25 21:32:04
Models
In this chapter, we will discuss the following topics:
- The importance of models
- Class diagrams
- Model structural patterns
- Model behavioral patterns
- Migrations
I was once consulted by a data analytics start-up in their early stages. Despite data retrieval being limited to a window of recent data, they had performance issues with page load sometimes taking several seconds. After analyzing their architecture, the problem seemed to be in their data model. However, migrating and transforming petabytes of structured live data seemed impossible.
"Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won't usually need your flowcharts; they'll be obvious."
— Fred Brooks, The Mythical Man-month
Traditionally, designing code around well thought-out data is always recommended. But in this age of big data, that advice has become more relevant. If your data model is poorly designed, the volume of data will eventually cause scalability and maintenance issues. I recommend using the following adage on how to balance code and data:
Rule of Representation: Fold knowledge into data so program logic can be stupid and robust.
Think about how you can move the complexity from code to data. It is always harder to understand logic in code compared to data. UNIX has used this philosophy very successfully by giving many simple tools that can be piped to perform any kind of manipulation on textual data.
Finally, data has greater longevity than code. Enterprises might decide to rewrite entire codebases because they don't meet their needs anymore, but the databases are usually maintained and even shared across applications.
Well-designed databases are more of an art than a science. This chapter will give you some fundamental principles such as Normalization and best practices around organizing your data. But before that, let's look at where data models fit in a Django application.
- Android Wearable Programming
- 微服務設計(第2版)
- Interactive Data Visualization with Python
- 算法基礎:打開程序設計之門
- OpenCV 3和Qt5計算機視覺應用開發
- Access 2010數據庫基礎與應用項目式教程(第3版)
- Visual C++應用開發
- Mastering Ext JS
- Hands-On Reinforcement Learning with Python
- NGINX Cookbook
- RESTful Java Web Services(Second Edition)
- Java程序設計基礎(第6版)
- Application Development with Parse using iOS SDK
- AutoCAD基礎教程
- jQuery Mobile Web Development Essentials(Second Edition)