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

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

主站蜘蛛池模板: 宁陵县| 甘孜县| 长垣县| 东丽区| 淮安市| 巴中市| 渝中区| 江津市| 宜丰县| 阳山县| 筠连县| 郸城县| 江都市| 泸定县| 望江县| 金平| 林芝县| 新安县| 黔西| 英山县| 满洲里市| 亚东县| 莲花县| 且末县| 漳州市| 塘沽区| 牙克石市| 南城县| 黄浦区| 瑞丽市| 古交市| 赤壁市| 潮州市| 自治县| 布拖县| 碌曲县| 凤山市| 舒兰市| 泰顺县| 凤阳县| 绩溪县|