in which we will store, for example, the articles published in this site. This
database will contain 2 tables:
- Table: article
Fields: id, title, author, published, length, updated, notes - Table: body
Fields: id, line_num, contents
% msqladmin create documents
% msql documents < schema.sql
create table article (
id char(10) NOT NULL, # unique ID
title char(200) NOT NULL, # title of the article
author char(200), # one or more, comma separated list
published int NOT NULL, # when was the article published
length int NOT NULL, # how many lines (each of 120 char length)
updated int, # when was it updated
notes text(80), # notes for internal use
)pg
create unique index article_idx on article ( id )pg
create table body (
id char(10) NOT NULL, # same as the article ID
line_num int, # line number
contents char(120) # a line of text from the article
)pg
create index body_idx on article ( id )pg
type, but using an INT type makes it easy for comparison using dates
in the form: yyyymmdd, e.g. 19990415 for April 15, 1999.
After setting up the database we populate it, and start having fun!