官术网_书友最值得收藏!

  • Learning Flask Framework
  • Matt Copperwaite Charles Leifer
  • 331字
  • 2021-07-30 10:18:34

Why use a relational database?

Our application's database is much more than a simple record of things that we need to save for future retrieval. If all we needed to do was save and retrieve data, we could easily use flat text files. The fact is, though, that we want to be able to perform interesting queries on our data. What's more, we want to do this efficiently and without reinventing the wheel. While non-relational databases (sometimes known as NoSQL databases) are very popular and have their place in the world of the web, relational databases long ago solved the common problems of filtering, sorting, aggregating, and joining tabular data. Relational databases allow us to define sets of data in a structured way that maintains the consistency of our data. Using relational databases also gives us, the developers, the freedom to focus on the parts of our app that matter.

In addition to efficiently performing ad hoc queries, a relational database server will also do the following:

  • Ensure that our data conforms to the rules set forth in the schema
  • Allow multiple people to access the database concurrently, while at the same time guaranteeing the consistency of the underlying data
  • Ensure that data, once saved, is not lost even in the event of an application crash

Relational databases and SQL, the programming language used with relational databases, are topics worthy of an entire book. Because this book is devoted to teaching you how to build apps with Flask, I will show you how to use a tool that has been widely adopted by the Python community for working with databases, namely, SQLAlchemy.

Note

SQLAlchemy abstracts away many of the complications of writing SQL queries, but there is no substitute for a deep understanding of SQL and the relational model. For that reason, if you are new to SQL, I would recommend that you check out the colorful book Learn SQL the Hard Way, Zed Shaw available online for free at http://sql.learncodethehardway.org/.

主站蜘蛛池模板: 临高县| 明溪县| 泗水县| 宜丰县| 大方县| 吉隆县| 内丘县| 新巴尔虎左旗| 治县。| 屏山县| 顺昌县| 和顺县| 花莲市| 沾益县| 郧西县| 巴彦淖尔市| 嘉义县| 美姑县| 福安市| 永登县| 广宁县| 鄂伦春自治旗| 仲巴县| 陵川县| 宁陵县| 玛纳斯县| 孟连| 商丘市| 色达县| 柯坪县| 新宁县| 永顺县| 金阳县| 广饶县| 金塔县| 香港| 夏河县| 巢湖市| 双桥区| 班玛县| 平果县|