Skip to Content
Beginning Lua Programming
book

Beginning Lua Programming

by Kurt Jung, Aaron Brown
February 2007
Beginner
672 pages
15h 34m
English
Wrox
Content preview from Beginning Lua Programming

Chapter 14. Managing Information with Databases

As a programmer, you'll sooner or later need to store information in between invocations of a program. You can store this information in a text file and decode it with patterns, or you can store it in a Lua file and reloade it with loadfile. But sometimes these methods aren't sufficiently fast, powerful, flexible, or scalable, in which case, you should store the information in a database. This chapter is a very brief introduction to databases and database systems. It will cover the following:

  • How data is organized in and retrieved from a database

  • SQL, the special-purpose language used to interact with databases

  • LuaSQL, a set of Lua bindings for a number of popular database systems

Some Basic Relational Database Concepts

This section demonstrates some basic database concepts by having you implement a simple database and a system for retrieving data from it entirely in Lua.

Almost all databases in use today are what are known as relational databases because they are designed to work with relationships between things (the previous generation of databases was not good at this). In the following example, the things in question are customers, products, and orders of an imaginary business. The relational aspect is the fact that the orders are defined in terms of the products ordered and the customers who ordered them.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Lua Quick Start Guide

Lua Quick Start Guide

Gabor Szauer
The Go Programming Language

The Go Programming Language

Alan A. A. Donovan, Brian W. Kernighan

Publisher Resources

ISBN: 9780470069172Purchase book