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

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/.

主站蜘蛛池模板: 柳河县| 博客| 兰西县| 武鸣县| 芜湖县| 申扎县| 东阿县| 临海市| 白玉县| 江源县| 屯昌县| 黎川县| 甘孜| 白水县| 灌阳县| 娱乐| 大新县| 临江市| 师宗县| 葫芦岛市| 宕昌县| 如东县| 安岳县| 金阳县| 黎平县| 长海县| 霍邱县| 永宁县| 惠来县| 綦江县| 康马县| 城固县| 玉屏| 称多县| 邮箱| 吉木萨尔县| 云和县| 山东| 梁平县| 衡东县| 长武县|