In this lab, we will learn about how we can create databases and use them to store data in our apps!
Create a new project in Anvil and add a data table service.
Make a new Data Table and name it.
Define your data columns
Enable the Uplink and get the key
Create a new Python file and add the necessary import statements
Program the script to collect the environmental data and save it into the database
Make sure to test your script!
Databases are a collection of data and information that is structured in a way that allows the user to store, retrieve, update or delete the data. There are many types of databases and depending on what kind of data we are trying to store, we will use a specific type of database.
Databases are used everywhere, from student information systems to the mobile games and apps you use on a daily basis. Each time you post on Instagram, you are actually adding to a database!
Flat databases are like spreadsheets – tables that organize data in rows and columns. These are useful for simple tasks like tracking student sign ups or exit tickets, but not as useful for complex apps.
CSV files, spreadsheets, XML files and others can be examples of Flat databases. They don’t offer, by themselves, any computational way to update those rows or columns.
Relational databases use different tables that have some relationship to each other. For example in a photo-sharing app, there would be a table for users, one for posts, one for comments, etc. These would be stand-alone tables, but would be aware of each other by linking data, like a user_id value with a table that contained just posts.
Non-relational databases, also known as NoSQL databases don’t rely on structured tables. They use different forms of storing and linking information, sometimes stored as JSON objects like in Firebase or Firestore, for example.
The first row is the names of each of the columns. Each row underneath is an entry in the database containing the relevant information.