Database Schema for SQL-Ledger

  • Updated to version SQL-Ledger 2.8.28

This schema description will introduce you to sql-ledger underlying database tables and will enable you to create your custom reports using SQL or import data using CSV import features of Postgresql. Please see sql queries for examples of SQL using this schema.

1. General comments on schema

1. Most tables have a primary key column named id. This key is appears as tablename_id as foreign key in other tables. For example customer_id column in tables is foreign key referring to id column in customer table. This id column gets unique sequence number from database sequence also named id.

2. Contrary to what new users might think customernumber, vendornumber, partnumber, invnumber etc. are not primary keys in customer, vendor, parts, ar/ap tables. These columns can also have duplicate values. You can prevent duplicate values by creating UNIQUE indexes on these columns. As mentioned above, in all tables, primary key is the column named id.

2. List of tables

  • acc_trans

Debit/credit records for all financial tranactions are stored in this table. trans_id is the foreign key in this table which refers to id in ar, ap, gl tables.

  • address
  • ap

Purchase invoices and AP transctions header information goes into this table. invoice column contains true for invoices and false for AP transactions.

  • ar

Sales invoices and AR transactions header information goes into this table. invoice column contains true for invoices and false for AP transactions.

  • assembly

Stores assembly components for a given assembly. id is id for the given assembly from parts table. parts_id is id for a assembly component from parts table.

  • audittrail

If you have activated the audittrial in System→Audit Control menu option, a row contain the username and transaction reference is inserted into this table for each transaction addition, deletion or editing activity. This table can grow very large on busy systems. You can also remove past audittrial record using System→Audit Control menu option. There are no reports in the system which show data from this table.

  • bank
  • br
  • business

Type of business. This table is used to group customers. You can also specify the discount percent applicable to that particular group of customers.

  • cargo
  • chart

This table contains Chart of accounts.

  • contact
  • curr
  • customer

Customer master record.

  • customertax

Customer-tax information is stored in this table. One row for each customer/tax combination.

  • defaults

System defaults

  • department

Departments

  • dpt_trans

Department transactions. One row for each transcation/deparmetn which contains a department reference.

  • employee

One row for each user/employee.

  • exchangerate

Exchange rate for a particular date is added to this table if you use foreign currency on a transaction and there is no exchange rate in this table for that transcation date. A maximum of two rates are added to this table for a given date. One for buy and one for sell.

  • gifi

General Index for Financial Information or GIFI allows you to create an alternate chart of accounts which can be linked to main chart of accounts through the GIFI column on Add Account form. Financial reports can be generated by accno or gifi_accno. You can also consider it an alternate method of group the accounts on chart.

  • gl

Contains one row for each general ledger transaction.

  • inventory

Inventory movement is recorded in this table when you use Ship or Receive options on ''Shipping' module.

  • invoice

Invoice detail lines for sales and purchase invoices go into this table. Qty is -ve for purchase invoices and +ve for sale invoices (unless you change sign when entering invoices for recording returns).

  • jcitems
  • language

One row per language defined. These languages are used to translate the parts descriptions into another language to print on invoices etc. Actual translations are stored in translation table.

  • makemodel

This table can contain one or more rows for any particular part. Make and model information is entered on Add Part screen. This information can be used to further classify or group the parts. For example you can specify which models use a particular part. You can filter on make/model on parts on Parts report.

  • oe

This tables records header information for four type of transactions; Sales Order, Purchase Order, Quotation and Request for Quotations. vendor_id is NULL if this is a Sales Order or Quotation. customer_id is NULL If this is a Purchase Order or RFQ. Boolean column quotation further differentiates between an Order and a Quotation.

  • orderitems

Detail lines for Orders and Quotations go into this table.

  • parts

Contains master records of parts, services, assembly, labour/overhead. inventory_accno_id is NULL for service items.

  • partscustomer

Per customer pricing for a part is stored in this table. This information is stored from Add Part form. Multiple prices with different quantity breaks can be entered for one customer.

  • partsgroup

Parts groups allow you to group your parts, services etc according to any criteria.

  • partstax

One row for each part/tax combination which is specified on Add Part screen.

  • partsvendor

Per vendor cost for a part as well as lead time and vendor part number are stored in this table. This information is updated through Add Part form.

  • payment
  • paymentmethod
  • pricegroup

One row per price group. Price group can be specified on the customer screen to group one or more customers to specific parts prices. You specify prices for parts group on Add Part screen.

  • project

One row per project. Project can be linked to sale, purchase or general ledger transaction detail lines. You can run reports filter them on projects.

  • recurring

Whenever you schedule a transaction, its id and other information for is stored in this table.

  • recurringemail

One row for each tranaction/formtype combination to be mailed when a recurrening transaction is created and marked to email one or more forms upon generation.

  • recurringprint

Same as recurringemail but for printing of forms.

  • semaphore
  • shipto

One row is added to this table when you create Ship To address in customer or vendor form. trans_id is the customer or vendor id for which shipto address has been created. A row is also added when you specify different shipto on invoice. In this case trans_id is the id of that transaction.

  • sic

Standard industry codes. Used to group customers.

  • status
  • tax

One row for each tax defined. Tax are defined by marking them Tax on Add Account form.

  • translation

One row for each description translated to a language defined in language table.

  • trf
  • vendor

Contains master records for each vendor.

  • vendortax

Taxes applicable to each vendor are defined in this table. One row for each vendor/tax combination.

  • vr
  • warehouse

One row for each warehouse defined.

  • yearend

You you run System→Yearend process, a journal transaction is generated in the gl table (with detail lines in acc_trans). id for the transaction along with the date is stored in this table. (one row per year end).

3. List of sequences

  • id
  • addressid
  • assemblyid
  • contactid
  • inventoryid
  • invoiceid
  • jcitemsid
  • orderitemsid
 
db_schema.txt · Last modified: 2010/05/06 12:05 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki