To help understand Mergeant usage, a simple example will be used throughout this documentation. This example comes from the 'examples' directory of the sources distribution of Mergeant.
It is the database used for managing the sales of a commercial company: several salesmen have each in charge one or more customers who can make orders which are composed of products stored in several warehouses.
The tables that have been created are:
'salesrep': a table which lists all the sales representatives of the company. For each of them there is an id (a number, key for the table), a name, a yearly salary, and the date of employment. The 'salesrep_id_seq' sequence ensures that each sales man has a unique id.
'customers': this table lists all the customers, with a unique id (using the 'customers_id_seq' sequence), a name, the city the customer comes from, and the id of the sales man who is in charge of the customer.
'orders': a table listing all the orders from all the customers. Each order has a unique id (from the 'orders_id_seq' sequence), the id of the customer who made the order, the date the order was made, the date before which the order must be ready for delivery, and the actual date of delivery.
'order_contents': as its name implies, this table contains all the products that are in an order; more specifically each entry in the table references the order id, the reference of a product, the quantity of that product in the order, and a discount percentage that has been allowed.
'products': a table listing all the products that the company sells. Each product is identified by a a reference, a name, a price, and the id of the warehouse where the product can be found (to simplify things, if a product can be in several warehouses, it is supposed to appear as several different references).
'warehouses': the list of the warehouses the company has. For each warehouse there is a unique id (from the 'warehouses_id_seq' sequence), the name and location of the warehouse.
To help understand the database structure, the figure below is a screenshot of the relations for all the tables'fields and sequences defined in the database: