Experiments
Select exercise
Help & theory

Introduction

Databases
A database is a set of properly systematized information. Currently, such data sets (DS) are most often located in computer systems. Such a computer database is managed by appropriate software called a Database Management System - DBSM. In particular, the DBMS allows for downloading or saving data and, for example, multi-access control.
Typically, when we talk about a database, we mean a data set DS and a DBMS.

Database = DS + DBMS

We have many different types of databases and they are used for different purposes. Therefore, they can be classified differently.
Databases are a very wide field of information technology (IT). This site is not dedicated to studying this field of IT. If you want to study this field, look for specialized courses on the topic (maybe here).
We discuss selected topics related to databases here only because they are also used in computer control. Currently, various devices controlled by systems based on so-called cloud databases are widely used. I mean, for example, various devices classified as elements of Smart Home systems.
On this website you will find examples of computer control of devices using databases available via the Internet.

Basic information about databases
Very often, especially in simple databases, data is stored in tables. One database may contain many tables, appropriately related to each other (relational databases). In the applications presented here, we will basically rely on very simple databases with only one table.
A database table resembles a spreadsheet in which data is stored in columns and rows - see figure below.
A record is a table row. Each record contains one or more fields. The fields correspond to the table columns. Fields must have a specific data type. For example: these may be fields intended for storing numerical, textual or time data, etc.
To sum up, a record is a single row in a table, i.e. a set of fields appearing in it.
Primary key is a field whose value uniquely identifies each record in the table. I will often use the term record ID instead. ID is an acronym for Identification Number.
A database password prevents unauthorized access to your data. If you know the password, you have access to certain data, for example stored in one record.

Imagine that you have 6 devices in fifferent places around the world that are connected to temperature sensors. Each device is connected to four such sensors. You want to store data from these devices. For this purpose, you can create a database with the structure as shown in the figure.

database

The database contains a table with six records (0 - 5). Each database record (table row) consists of 7 fields (table columns 0 - 6). We have fields for storing numeric data (ID, Temp1, Temp2, Temp3, Temp4) and text data (Pass, Localization). I dedicated the Pass field to store the password.

A query is a request to a database.
A database query can be an functional query or a select query. A select query is one that retrieves data from a database. A functional query asks for additional data operations, such as inserting, updating, deleting, or other forms of data manipulation. These operations are performed by the DBMS system at the request of the database user. For the database to understand the requirements, it must receive a query in the appropriate syntax. There are special languages for creating queries. For example, SQL is a very well-known and widely used language for communicating with databases (SQL = Structured Query Language).

Imagine that the database with our sample table is installed on a computer in Tokyo, which is a suitable server connected to the Internet. So we have an web database. While in Cairo, you can send a query via the Internet and find out what temperature was measured by sensor No. 4 in London. In this query, you must specify: record number (ID), password (Pass) and determine the field or fields from which you want to retrieve data. To do this, you need to know the format and syntax of the query language.

In various sections of this website we will use and query so-called web databases. It will then turn out that we do not always have to learn some complex language for creating queries.

API
The database API allows applications to interact with a remote database to access and manipulate data (API = Application Programming Interface). In a simple case, it may be only a few commands that can be easily attached to HTTP service requests sent to the database server. Such a command will invoke the appropriate function of the server application. Based on the data attached to the command, the server will perform the requested operation on the data and return the result. For example, this may be reading data from the appropriate field of a selected database record.
Sounds not very clear? Time for practical exercises that will explain everything.

Experiential learning
I have prepared a web database for you with a table exactly the same as in the picture above. A description of the API functions and instructions on how to use them can be found in the "Experiments" menu on the left side of the screen. Click on the Example_001 item.



Here is the minimum knowledge you need to know to start creating web applications. This description and recommended experiment should be enough for you to understand the concept of many models of computer control based on computer networks.
The menu on the right contains redirections to various descriptions of other topics that are needed to implement cloud databases.