![]() |
![]() |
![]() |
Libgnomedb Reference Manual | ![]() |
---|
The database structure is described in the next paragraphs (in PostgreSQL's syntax in this example):
The 'id' field is the primary key of this table.
CREATE TABLE customers ( id serial NOT NULL, name character varying(35) NOT NULL, default_served_by integer, country character varying(20), city character varying(30) );
Each row in the table represents an order passed by a customer. The customer is identified through a foreign key (the 'customer' field). The 'id' field is the primary key of this table.
CREATE TABLE orders ( id serial NOT NULL, customer integer NOT NULL, creation_date date DEFAULT now() NOT NULL, delivery_before date, delivery_date date );
Each row in the table represents an item in an order. The referenced order is identified through a foreign key (the 'order_id' field); the referenced item is identified through the 'product_ref' foreign key. This table has no primary key.
CREATE TABLE order_contents ( order_id integer NOT NULL, product_ref character varying(15) NOT NULL, quantity integer DEFAULT 1 NOT NULL, discount double precision DEFAULT 0 NOT NULL );
<< A small example | Coding the application >> |