Extensions to the C API

SQLite binding functionality extends the popularity and diversity of the SQLite language, but it is not supported by the core developers of the database. Instead, the SQLite community takes care of these integrations, and is well-documented online. Scripting languages, such as Perl, PHP, and Python or Java, work nicely with SQLite.

The C API interface specification for SQLite has several interface elements and can be grouped into the following categories:

For example, the int sqlite3_sleep(int); function is based on the number of milliseconds that it will suspend the execution of an instruction.

As mobiles become more powerful, there will always be an alteration to the amount of memory resources that SQLite can handle or use. The technology that is used within SQLite is called page cache. Now, page caching is important since this is how memory is used and set up for the SQLite performance. It has one I/O algorithm and two search algorithms. There is a binary search that uses the index of the table and full on brutal attack to read the full table. Since the limited decisions were made about how to write and implement them, and since it is more general and not designed for any specific application, the performance generally may not be equal to what is expected.

Although, SQLite does have an optimizer, it is not the most advanced of its type, but it is practical. In the following example, we see the creation of two tables and a join. We will use the EXPLAIN statement and then ask SQLite to see how it would get the results. As the results will begin to show, it will use one of the category formats discussed earlier in this section, which is just a major scan. It will only work properly if there is a SELECT statement with JOIN but with an index or a key on a simple query. On a complex query, you need to use the EXPLAIN statement. We just select one column from the first table and a scan of the whole table takes place:

sqlite> CREATE TABLE one (y, z);
sqlite> CREATE TABLE two (a, b);
sqlite> EXPLAIN QUERY PLAN SELECT A FROM one JOIN two ON one.z = two.b WHERE y = 30;

0|0|TABLE one
1|1|TABLE two

In terms of page cache, SQLite, as mentioned earlier, uses a disk with a page-based format. The cache along with SQLite is pulled from disk. There is no automatic recycling of pages; it can be reused once the page is empty. Also, if a page is reused again and again, it will become fragmented, and its data will be spread across the database file, which will decrease in terms of the performance.

As mentioned previously in this book, there is Core Data from Apple, standard for iOS, but SQLite, which is free, is the dominant and cross-platform database solution for mobile.

With the advancement of new frameworks, there is a new technology, which aims to replace both: SQLite and Core Data. It is called Realm. It is free for both iOS and Android and would be a good product to investigate. While the others maybe limited, this product must ensure that it is easy to set up, use, and administer. So far, it is being used by a variety of large e-commerce and data sites, such as Pinterest or BBC. Realm.io is the location for this database software, is modern API for today's changeable market.

With Realm, there is a plugin for Xcode, which seems to hook in and work well as per the demo. There is a complete API reference, which works with Objective-C, Swift, and Java. Realm also has its own Realm Browser from the Apple app store, which is used as an app to manage the databases, such as the Firefox plugin for SQLite.