For the More Curious: More Databases

For the sake of space and simplicity, we do not go into all the details you might see in a professional app’s application database here. There is a reason people resort to tools like ORMs: This stuff can get complicated.

For a more substantial application, you will want to look into adding the following to your database and your description of it:

  • Data types on columns. Technically, SQLite does not have typed columns, so you can get by without them. Giving SQLite hints is kinder, though.

  • Indexes. Queries against columns with appropriate indexes are much faster than columns without them.

  • Foreign keys. Your database here only has one table, but associated data would need foreign key constraints, too.

There are also deeper performance considerations to dive into. Your app creates a new list of all-new Crime objects every time you query the database. A high-performance app would optimize this by recycling instances of Crime or by treating them like an in-memory object store (like you did before this chapter). That ends up being quite a bit more code, so this is another problem ORMs often try to solve.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.42.196