MySQL for the Internet of Things

(Steven Felgate) #1

Chapter 5 ■ MySQL priMer


■Note i will show you how to install MySQL on the raspberry pi and similar boards in Chapter 6.


What IS a reLatIONaL DataBaSe MaNaGeMeNt SYSteM?


an rDBMS is a data storage and retrieval service based on the relational Model of Data as proposed
by e. F. Codd in 1970. these systems are the standard storage mechanism for structured data. a great
deal of research is devoted to refining the essential model proposed by Codd, as discussed by C. J. Date
in The Database Relational Model: A Retrospective Review and Analysis.^6 this evolution of theory and
practice is best documented in The Third Manifesto.^7

the relational model is an intuitive concept of a storage repository (database) that can be easily queried
by using a mechanism called a query language to retrieve, update, and insert data. Many vendors
have implemented the relational model because it has a sound systematic theory, a firm mathematical
foundation, and a simple structure. the most commonly used query mechanism is SQL, which
resembles natural language. although SQL is not included in the relational model, it provides an integral
part of the practical application of the relational model in rDBMSs.

The data are represented as related pieces of information (attributes or columns sometimes called fields)
about a certain event or entity. The set of values for the attributes is formed as a tuple (sometimes called a
record or row). Tuples are stored in tables that have the same set of attributes. Tables can then be related to
other tables through constraints on keys, attributes, and tuples.
Tables can have special mappings of columns called indexes that permit you to read the data in a
specific order. Indexes are also useful for fast retrieval of rows that match the value(s) of the indexed
columns.


How and Where MySQL Stores Data


The MySQL database system stores data via an interesting mechanism of programmatic isolation called
a storage engine that is governed by the handler interface. The handler interface permits the use of
interchangeable storage components in the MySQL server so that the parser, the optimizer, and all manner
of components can interact in storing data on disk using a common mechanism. This is also referred to as a
pluggable storage engine.


■Note MySQL supports several storage engines. Most are designed to write data to disk by default.


however, the MeMOry storage engine stores data in memory but is not persistent. that is, when the computer


is rebooted, the data is lost. you can use the MeMOry storage engine for fast lookup tables. indeed, one


optimization technique is to create copies of lookup tables at startup using the MeMOry storage engine.


(^6) C. J. Date, The Database Relational Model: A Retrospective Review and Analysis (Reading, MA: Addison-Wesley, 2001).
(^7) C. J. Date and H. Darwen, Foundation for Future Database Systems: The Third Manifesto (Reading, MA: Addison-
Wesley, 2000).

Free download pdf