[b:kixjxipc][size=150:kixjxipc]A Sample Invoicing application
[/size:kixjxipc][/b:kixjxipc]
[b:kixjxipc]Adapted from \fwh\samples\yunus.prg[/b:kixjxipc]
An approach that can be adopted for quotations, purchase orders, etc.
[u:kixjxipc][b:kixjxipc]mariainv.prg[/b:kixjxipc][/u:kixjxipc]
[b:kixjxipc]Points of interest:[/b:kixjxipc]
1) Implementation of Transactions.
2) Database integrity at server level through
a) Foreign key relationships
b) Unique constraints
c) column validations
d) calculation of dependent columns
e) updation of related tables
f) ENUM type of column
3) Triggers and stored procedures
[b:kixjxipc]Lack of support for CHECK constraint in MySql and MariaDB (latest stable version).[/b:kixjxipc]
Other databases support CHECK constraint like this:
[code=fw:kixjxipc][/code:kixjxipc]
This constraint rejects any updation of insertion with value of price <= 0. Sadly both MySql and present stable release of MariaDB do not support this constraint.
For this reason, we had to implement such constraints through Triggers. If this constraint is supported, we do not need to write all these Triggers. It is understood that latest builds of MariaDB support this constraint.
[b:kixjxipc]Foreign key relationships:[/b:kixjxipc]
These constraints eliminate the possibility of buggy front-ends writing invalid data. Please see the difference in definition of these constraints. The relationship of INVNUM in invitems and invoices is defined in such a way that if an invoie is deleted all the related entries in the child table also are deleted automatically, whereas in case of clients and items any attempt to delete an entry which is already used by invoices,invitems tables is rejected.
[b:kixjxipc]Calculated columns:[/b:kixjxipc]
Calculation of dependent columns is implemented at server level through Triggers. MySql 5.7 and present stable release of MariaDB implement Calculated Columns. FWHMARIADB library supports calculated columns when supported by the server.
When creating table using oCn:CreateTable, the column may be defined as:
[code=fw:kixjxipc][/code:kixjxipc]
In this sample we did not adopt this approach. Instead we implemented calculations inside Trigger so that the logic can work even on earier versions of MYSQL servers.
[b:kixjxipc]Column type ENUM (implemented by MySql):
[/b:kixjxipc]
Please see the column definition
[code=fw:kixjxipc][/code:kixjxipc]
This column allows only one of the values in the list.
FWMYSQL not only supports this column type, but also uses the information to automatically build EDIT_LIST_BOX in xbrowse and datarow without any effort by the programmer.
Please try editing "Items"
[code=fw:kixjxipc][/code:kixjxipc]
[url=https://imageshack.com/i/pmtNtCYfj:kixjxipc][img:kixjxipc]http://imagizer.imageshack.us/v2/xq90/922/tNtCYf.jpg[/img:kixjxipc][/url:kixjxipc]
Download Link:
↧