Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback



Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi








Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (19)


To place a business logic in server sideGo to Mike Shkolnik's websiteFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi all versions
Category:
Multi-Tier
Skill Level:
Scoring:
Last Update:
05/23/2000
Search Keys:
delphi delphi3000 article borland vcl code-snippet multi-tier business logic objects server database
Times Scored:
10
Visits:
15863
Uploader: Mike Shkolnik
Company: Scalabium Software
Reference:
 
Question/Problem/Abstract:
How to store a business objects in database tables?
Answer:



The devlopment of large projects is hard work. Especially when our clients are remote/mobil users.Also in our life exists the task which are not stay on one place and which algorithm changes in time. In these situations we must to develop the multi-tier application and store the business logic in server-app level. But for some tasks this way is very expensive. So I prefers the some "2 1/2"-tier level when part of business logic we can store in database. I'll try to describe this my opinion.


On server database I have a few own "system" tables with descriptions of project:
1. CLASS table is a list of all available user queries with short
description, select/update/insert/delete statements
2. DESCRIPTION table stores the descriptions of fields for each record in CLASS
3. a few additional tables with security (user, groups, privileges, access modes etc)
  PS I do not describe them, as for the basic description they are not so important


In application I have a main datamodule, which contains the
one TDatabase component (linked to my BDE alias or ADO connection).
Also I have a some TDataModule component which are the parent for each other. On this component I dropped the TQuery (linked to main TDatabase), and TUpdateSQL and TDataSource, which are linked to TQuery.

Also in this parent datamodule I included the some additional properties and procedures/functions:
1. to get a descriptions from server by class name
2. to fill a update/delete/insert properties of TUpdateSQL
3. to change a filter (via where clause), a data order (via order by) etc (any clause in sql - I use a some macros in own sqls)
4. post/cancel changes in server database, refresh data
5. to get the new ID (for autoincremental fields)
6. to read a user privileges
7. to open class
8. to get a "lookup" class
   PS: I not use a delphi lookup fields. Instead it I store in class descriptions for some fields the additional info (which class I must open for edit/view of data, which fields are linked in "lookup" class etc and more)
9. and more additional features

Each datamodule are successor of this parent DM with "personal" extension in business logic. For example, in the class for details of orders I defined the specific calculations (some subtotals and sums) or procedures (check of outputing qnt). The full logic I included in these DMs only (in visual forms
I use a calls only!).

Also I have a basic visual TForm with grid, navigator, filter panel etc.
This form have a "linked" DataModule. Also this form known how:
1. to fill the info from DM (a columns list for dbgrid (from description in DM), form caption and more)
2. to call a form for edit/append of record (those form not uses the any DB-components!!)
3. to generate report (I use a SMReport)
4. to export data (I use a SMExport)
5. to find a record by some criteria
6. to select a records (the some forms I use for selecting of some recors)
  PS: for example, in orders mode my users can select a records from product class and append the wished

7. to open a "lookup" class
  PS: for example, in grid with customer list my users can open a class of customer types (instead standard delphi lookup field) or "drill" in orders list for this customer

8. to setup the visualization of data (fonts, colors, order etc, filter, sort and grouping)
9. and more additional features

All the rest forms inherits from this parent and are different one from other in needed possibilities only. For example, if my users want to calculate a sum of some order for specific product type only, of course, I add a calc function in linked DM and drop a button on form for calling of this function in DM

PS: in visual forms (when I need to calc or to do a something) I call the "assigned" method in "assigned" DM.


Also I have a two list - opened DMs and created forms. So if I need open a "lookup" class, I search it in list of DM and create only if I not found.
And with forms I work similar.

Using this schema I can devide the project from my "2 1/2"-tier level on multi-tier in few simple operations (because the all business logic I store in database on db-server and mine DM-classes. The visual forms not contains the logic - only visualization).

PS: this technology I uses in tens projects (current and finished), in small app and in big projects. I described the customers-orders-products schema for availability of understanding only. Of course, sometimes (more often in the beginning of development of small app) the perspective of the extension of functionality up to large client-server
system (and especially multi-tier) is not visible and it's possible to go on easy way - drop on form the ttables (or even to allocate them in separate datamodule), linked it with grids, use a master-detail link and lookup fields etc
But when you decide to expand possibilities of the app and transfer it from local DB (Paradox/DBase/Access etc) on normal DB server and maybe use a 3-tier you will understand, that is necessary to change the approach to DB programming for rise of productivity, easy support and extension of project.

Of course, it's my opinion only, but I have come to such technology by many cuts and tries during 10 years on different DBs and tools of development. Though I still do not have also thirty years I have a  large number of successful developments in other departs and if I can to someone reduce this long way, it will be well.

I do not apply for indisputable true and I know many weak places
in the described technology, but they not impasses - it is simply
not up to the end are realized (and it's good:)))
I'll read criticism of other with pleasure too.





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
send me the example please... its so important to me
    drake draculasexy (Sep 9 2005 10:09AM)

i want the example please... its so important to me...
thanks alot
Respond

Please send sample to me
    Ackravuth Kawjamnong (Jan 11 2005 9:42AM)

Please....Thank you very much
Respond

Greatest!
    Eduardo Ochoa (Apr 15 2004 6:52PM)

Please send me some examples?!
eochoa@reyma.com.mx
Respond

Sample Demo
    Hifni Nazeer (Apr 8 2004 7:35AM)

Most people need some samples to understand and it seems, lot have requested from the Author. So isn't it possible to include a sample demo along this article so that everybody could access and see it.
Respond

Sample?
    Duc Lam Vu (Jun 21 2003 7:28AM)

I also nedd some examples. Could you send me?. Thanks a lot.
Respond

I need sample
    ale six (Apr 21 2003 4:00PM)

please send me a sample
Respond

PLEASE
    ESMHOA (Nov 16 2002 11:27AM)

PLEASE SEND TO ME Example
ESMHOA@YAHOO.COM
Respond

Sample project
    bernard ocloo (Apr 27 2002 4:42PM)

Do you have a sample project illustrating this approach ?
Thanks
Respond

Please send me some examples?!
    Juan J. Martinez Alonso (Oct 15 2001 12:51PM)

Please send me some examples?!
vegabaja@ctv.es

Thanks.
Respond

Great Article
    Andrew Black (Sep 9 2001 7:45AM)

Please send me some examples?!

andrew@gigabias.com

big thank
Respond

Great Solution
    Gerardo Fernandez (Aug 9 2001 9:22PM)

Mike,

I think your solution is great. Can you send me a little demo please?

Thanks

Gerardo Fernandez
gifm@tutopia.com
Respond

Similar technology
    Josir (Aug 4 2000 3:08PM)

I use a very similar approach (with form, datamodule and report inheritance)
except on the Lookup class.

How do you implement the lookup class on a grid, for example ?
Could you share some code ?


Respond

Sample?
    Gerardo Fernandez (Jul 22 2000 11:29PM)

Please, could you send me a sample?

Thanks

Gerardo Fernandez
gidm@uol.com.mx
Respond

about demo
    Mike Shkolnik (Jun 13 2000 11:43AM)

Friends,

I used this schema in the own commercial projects but I haven`t a small free demo.
If someone have the additional questions, please forward them to me in private mailbox and I`ll try to answer.
Respond

Do you have a sample
    John Minker (Jun 12 2000 10:47PM)

This sounds great!!! Do you have an example that you could send me?

Thanks!!!!
Respond

RE: Do you have a sample
Arnold Diaz (Jul 23 2001 2:41PM)

send me one pleasssssse...thanks!
email me at arnold@aspacmanila.com.ph
Respond

Great ideal
    anonymus (May 30 2000 3:02PM)

That's great Ideal.
Can you mail sample to me ?
Thank


Respond

Sample?
    anonymus (May 23 2000 2:27PM)

Do you have some sample?
Please.


Respond

RE: Sample?
Good!! (May 29 2002 2:52AM)

Can you mail sample to me,too ?
Thank  you




Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
D. Souchard
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)