- This series is going to be dedicated to the basic to Android development. Join me and let us try to build and understand some cool stuff. I used the Android documentation and all other resources I used can be found HERE.
- Before we can talk about the SQLite database system we should talk about SQL and the basics of databases.
Entity : something inside of our database system.
Table : a set of rows, held in memory
Row : a set of columns that collectively describe an entity.
Column : an individual piece of data stored in a table
- Really a database is nothing more than a set of related information. So by that definition an old school paper phonebook is a database. To more accurately describe modern electronic databases we will refer to electronic databases as
- So traditionally database systems stored information in a hierarchal database system. Which has a very similar look to a family tree. These kind of database systems rained supreme until the relational model was created.
- In 1970 Dr.E.F Codd of IBM's reasearch team published a paper titled,
A relational model of data for large shared data banks. This paper proposed that data be represented as a set of tables.
- When Dr. Codd wrote his paper on relational database systems he also created a language called
DSLfor manipulating data in a relational model. This language eventually led to the creation of SQL. So SQL is the language that we use inside of relational database systems to manipulate data.
- As the official SQLite documentation states,
do not be mislead by the lite in the name. SQLite is a full featured SQL implementation. So we now know this means it is a database systems that implements the relational data model and uses SQL to manipulate data.
- Fun fact, SQLite is actually the most used database system in the world. With both Android and IOS systems using it.
- Well in the dark ages of android development we would use the SQLite API directly, which has a fairly steep learning cure. However, today we now use the
Room Libraryto create and manipulate data on Android.
- Room is an abstraction over the SQLite database system making things easier to use. Room provides 3 main advantages to the plain SQLite API
1) Compile time verification : this means that if we have an error in our queries we will know about it immediately.
2) Convenient annotations : easy to use
@ annotations that minimize the amount of boiler code that we have to write.
3) Migration : streamlined database migration paths.
- inside of the Room library there are 3 major components
1) Database Class : this class holds and represents the main access point to our applications persisted data.
2) Data Entities : represent tables in our app's database system.
3) Database Access Objects (DAO) : provides methods that our app can use to query, update, insert and delete data in the database system
- Thank you for taking the time out of your day to read this blog post of mine. If you have any questions or concerns please comment below or reach out to me on Twitter.