关于数据库的连接结构问题(探讨一下)(100分)

  • 主题发起人 主题发起人 shyj
  • 开始时间 开始时间
S

shyj

Unregistered / Unconfirmed
GUEST, unregistred user!
关于在C/S结构时TDatabse构件的使用方法
my ways one:
use one Tdatabse control to manager all tquery like user's
login,visiting data and so on. struct as following:

[Tdatabase] in first TDataModule1
/ | /
/ | /
tquerys in Dmo2 tquerys in Dmo3 ...

advantage:
only link server one times. manage easy.etc..
shortcoming:
link is always open.And I think it is not ideal
every tquery link server only using one link.
can anyone explain it clearly better?
my ways two;
use multi tdatabase(every module use one)
advantage:
dynamic manage sever's link...
shorecoming:
link multi times,it may delay time...

I want to know what is friends here linking ways and
datamudle structure of program.
This discuss' goal is minimum links of server and
enough speed.
thanx all.





 
不太明白你的意思;)

1、用一个database挺好的,数据库始终打开这没什么
2、多个Query用一个database效率挺高的呀
3、如果是对同一个数据库操作,用多个database干什么呢

 
一个Database一般是够用了,如果对同一表或查询有不同的处理要求,如:BeforePost等
事件处理不一样,那得用多个Database.
你的情况一个应该没问题.
 
Your suggestion is good, not only save the linkage, but also the
resource, but multi tdatabase is rarely used except you have multi
database server (MSSQL, ORACLE, SYBASE...), in fact, you can define
the connect string at run time to manage all these different server
link, change connect string of the tdatabase when you want to change
database server,

if you have multi datamodule, (dm1,dm2...),then you can specify tquery
in these module to dm1.

No metter how many links you want to using, the most important thing
you sould remember is:
close the dataset after it finish the job, that will save much more
then the linkage.
 
在multithread情况下最好还是每个query对应一个单独的database和单独的session(防止冲突)
 
eYes: I think one database and one autonamed session is enough"_
 
cj, u think so. but if BDE think so?

think about this: if u have only 1 database. and now 2 clients apply
updates(or query) at the same time(same table).

remember this, there's only 1 database and 1 globle session.

what will happen?
 
To everyone,
thx for everyone's discuss.
New discuss as following:
About amout of linkage to server,how to calculate this amount?
ways one:
One Tdatabase who is always open has one time?
nAmount =1
Every TQuery who is open and query data has one time.
nAmount = nAmount + 1;
Every TTable who is open has one time.(I never use it in program)
nAmount = nAmount + 1??
...
ways two:
One Tdatabase who is always open has one time.And times dont
care tquery'linkage and ttable' linkage etc.
So, can I make zero time of linkage to server when program works?
My idea as following:
Having downloaded data from server,Tdatabase close.And only
when updating data to server,Tdatabase open.But I think it may
too slow when close -> open.So this discuss is put forward.
BTW: I have only seldom amount of linkage which
mentioned in copyright.

 
dear eYes:
so I sugess a AUTO-NAMED SESSION to solve this problem:-)
 
多人接受答案了。
 
后退
顶部