Oleksiy Mark - Fotolia
Vintage wines, yes; vintage databases, not so much. For the 20 million oenophiles who use Vivino to contribute ratings for millions of wines, Realm Mobile Database was the perfect pairing. If your database of choice used in your application is based on technology that predates 2014, it wasn't conceived with cloud-based mobile computing in mind.
One of the major shortcomings for developers and users alike was the database implementation on mobile devices. "The database is more or less a cache of the user's own wine list, data about wine styles and other things needed for the user to work offline," said Kasper Weibel Nielsen-Refs, iOS team lead at Vivino, based in Copenhagen, Denmark.
Refactoring the code base with Apple's Swift afforded the team an opportunity to simultaneously move away from its SQLite databases. Database response is crucial to one of Vivino's key features in which users can use their smart device to take a photo of any wine label and instantly learn that wine's rating, read reviews and check average prices.
"When I came to Vivino, the application had been developed very rapidly in India, but the quality was not high," Nielsen-Refs said. "Adding new features was difficult, so we moved our team to Copenhagen to have more direct control over quality and pay back what amounted to a three-year technical debt."
Objective-C had to go
Early on, developers decided to replace the Vivino application's 15,000 lines of mostly Objective-C code with new code, including the use of open source Apple Swift, which could handle frequent updates and an expected explosion in users. "It was becoming difficult to make updates, so it needed to go," Nielsen-Refs said.
Kasper Weibel Nielsen-RefsiOS team lead, Vivino
Another prime consideration was the need to provide mobile users with offline access to their own wine data via caching. Even with Swift, the Vivino team had concerns about it being a young, evolving platform. "We are monitoring the development of Swift; it is a language that is moving forward at a rapid pace. We implemented some code in Swift, and we can now see that we have to update everything. It is quite a big investment to refactor everything, and we have to check every month to see where Swift is now."
The prediction of a rapidly growing user base was spot on, highlighting the need for a native mobile database. According to Nielsen-Refs, Vivino, which is hosted on Amazon Web Services, has been downloaded from app stores more than 20 million times, and it's adding 30,000 new users daily. Users, in turn, are adding 300,000 wine entries every month. "It adds up to more than 10 million wines in our database from 210,000 different wineries," he said. The company releases an app update every two weeks containing the usual mixture of feature enhancements, performance tweaks and bug fixes.
On iOS, Vivino had a choice between Apple's Core Data and Realm Mobile Database.
Built for mobile
SQLite was created in 2000 for the U.S. Navy to use on guided-missile destroyers, according to Paul Kopacki, vice president for business strategy at Realm, based in San Francisco. "Today, it is a square peg pounded into the round hole that is mobile app development, and yet it's the default for most Android and iOS apps," he said.
Core Data, Kopacki said, amounts to object relational mapping on top of SQLite. "It's a table-based database, so when you're trying to write object-oriented code, you have to do object-relational mapping that requires a lot of convoluted translation work to get your data model to map to your logical model."
Realm, conceived as a mobile database, was launched in July 2014. It takes a different approach in that it is an on-device, cross-platform object database. Data is stored as objects, which, according to Nielsen-Refs, makes things "infinitely easier for developers." Without the need to do mapping, it can also be implemented more quickly. The database also features built-in encryption.
According to Realm, the mobile database is used in production for the customer loyalty and e-commerce platforms of Starbucks, SAP's Concur corporate expense management app, and Budweiser's Tapweiser restaurant and bar order and inventory app.
Realm updates automatically
In Realm, objects are always live, meaning they update automatically and immediately in response to changes. That, in turn, simplifies mobile event processing; real-time, two-way and internet-of-things sensor synchronization; and offline experiences.
The company recently expanded its offerings with the Realm Mobile Platform, an object-based mobile-app platform that integrates a client-side mobile database software development kit with servers and offers real-time, two-way data sync and event handling. It supports Android and iOS, and it can run either on premises or on any major cloud platform.
"Developing for Realm was faster than Core Data, which was quite complex," Nielsen-Refs said. His advice for application developers considering a mobile -- or any other -- database is to keep the inevitable need to scale in mind. "If you have an app and start small, there will come a time when you need to scale to millions of users or objects. Everything you choose -- the data model, programming language and database -- makes a big difference as the number of users grow."
Mobile analytics: You need it -- now
Security controls in Swift required by 2018
Top mobile app-development tips