SQLite Database Tutorial: GuitarClub, part 2Structure of the database and the tablesLet's add a table for the guitars. In addition to the table Members, the database GuitarClub.db now contains a second table named Guitars, with the details of each guitar. Its columns (aka "fields") are as follows:
Note: the last field ID points to the field ID in table Members. It is used for setting up the master/detail relationship between Members and Guitars. GuitarClub project with 2 tablesFor this project, create a folder FPlaz\SQLite02, download SQLite02.zip and unzip to this folder.
When you look at the source code, you'll see that it is a bit more explicit than before.
The relationship between the tables is defined in the where clause of this line: queryGuitars.SQL.Text := 'select * from Guitars where Guitars.memberid = :id'; The colon : at the start of :id means: this is a so-called foreign key, in other words: it references a field in another table, it references the field ID in table Members. |
![]() Table of contents » SQlite » GuitarClub part 1 » DB Browser for SQLite » GuitarClub part 2 » GuitarClub part 3 » Report generator » Master/detail report |