1

Topic: Display of lines of the table of basis in objects?

We take for an example the elementary table: CREATE TABLE tbl (key INTEGER PRIMARY KEY, cap TEXT NOT NULL); If to interpose new record with a field cap ='AAA ' (INSERT), to delete it (DELETE) and to interpose new (INSERT) with cap ='BBB '. Then in sqlite record with cap ='AAA ' and c cap ='BBB ' will have identical "key" (remote record with cap ='AAA ' means had we tell key=1, and new record will have too key=1). I develop application which should allow to open the same record in different independent windows (is more true the set of records intersection which can not zero, but for simplification we will be restricted to one record). And here we admit read any record from the table, transformed it into object, and opened this object in several windows. In one window we pushed the button to delete, then created new record, at this time at all of us still openly third window in which data of already remote record, we in it admit something we change and we push to save, and the nonsense any turns out if to use "key" as a unique identifier of object of basis. What in such cases do, enter type "cache" between classes responsible for operation with basis and the program, and all GUI working with basis subscribe for events of "cache" and if in one window the object is deleted "cache" informs windows that such object is not present?

2

Re: Display of lines of the table of basis in objects?

Hello, dave_2, you wrote: _> we Take for an example the elementary table: _> _> CREATE TABLE tbl (key INTEGER PRIMARY KEY, cap TEXT NOT NULL); _> _> If to interpose new record with a field cap ='AAA ' (INSERT) to delete it (DELETE) _> and to interpose new (INSERT) with cap ='BBB '. _> Then in sqlite record with cap ='AAA ' and c cap ='BBB ' _> will have identical "key" (remote record with cap ='AAA ' _> means had we tell key=1, and new record will have too key=1). _> I develop application which should allow _> to open the same record in different independent windows (is more true the set _> than records intersection which can not zero, but for simplification we will be restricted _> to one record). _> And here we admit read any record from the table, _> transformed it into object, and opened this object in several windows. _> In one window we pushed the button to delete, then created new record, _> at this time at all of us still openly third window in which data already _> remote record, we in it admit something we change and we push to save, _> and the nonsense any turns out if to use "key" as unique _> the identifier of object of basis. _> that in such cases do, enter type "cache" between classes answering _> for operation with basis and the program, and all GUI working with basis subscribe _> for events of "cache" and if in one window the object is deleted "cache" informs _> windows that such object is not present? From the point of view  here all  - all entities have unique primary key. The problem arises that clients work with different versions of the data. Decisions: to use transactions, to select natural unique or primary key, to recustomize that that in sqllite that the primary key repeatedly would not be used.

3

Re: Display of lines of the table of basis in objects?

Hello, Qulac, you wrote: Q> Hello, dave_2, you wrote: _>> That in such cases do, enter type "cache" between classes answering _>> for operation with basis and the program, and all GUI working with basis subscribe _>> for events of "cache" and if in one window the object is deleted "cache" informs _>> windows that such object is not present? Q> From the point of view  here all  - all entities have unique primary key. The problem arises that clients work with different versions of the data. Decisions:> to use transactions And how it helps? In the scenario described by me it will be caused "update" with  a key, another matter that we want to update the old version of the data, and it is updated the new. That is sql the part fulfills without questions and errors.> to select natural unique or primary key to recustomize that that in sqllite that the primary key repeatedly would not be used. It is possible to expose properties of primary key AUTOINCREMENT and then all will be good, but strains that when business reaches to 2^64-1 more record of objects will be impossible (restriction sqlite). On idea the user for 1000 does not reach the such, but strains.

4

Re: Display of lines of the table of basis in objects?

Hello, dave_2, you wrote: _> Hello, Qulac, you wrote: Q>> Hello, dave_2, you wrote: _>>> That in such cases do, enter type "cache" between classes answering _>>> for operation with basis and the program, and all GUI working with basis subscribe _>>> for events of "cache" and if in one window the object is deleted "cache" informs _>>> windows that such object is not present? Q>> From the point of view  here all  - all entities have unique primary key. The problem arises that clients work with different versions of the data. Decisions:>> to use transactions, _> And how it helps? In the scenario described by me it will be caused "update" with  a key, _> another matter that we want to update the old version of the data, and it is updated the new. That is sql the part _> fulfills without questions and errors. Meant not to allow to several users to change the same data or to use optimistic lock. >> to select natural unique or primary key to recustomize that that in sqllite that the primary key repeatedly would not be used. _> It is possible to expose properties of primary key AUTOINCREMENT and then all will be good, _> but strains that when business reaches to 2^64-1 more record of objects will be impossible (restriction sqlite). _> On idea the user for 1000 does not reach the such, but strains. And 10000 will not strain?

5

Re: Display of lines of the table of basis in objects?

Hello, dave_2, you wrote: _> That in such cases do, enter type "cache" between classes answering _> for operation with basis and the program, and all GUI working with basis subscribe _> for events of "cache" and if in one window the object is deleted "cache" informs _> windows that such object is not present? Approximately so, it only is called not "cache", and locks. At the editing beginning in shape there is an attempt to block object in a DB. If it is already blocked, the user receives the error report. These are so-called pessimistic locks. Happen still optimistic, but for simplicity yet we will not be about them. SQLite does not support lock at level of separate lines, only the table entirely. It is necessary or implement them in application, or to replace a DBMS.

6

Re: Display of lines of the table of basis in objects?

Hello, wildwind, you wrote: W> Approximately so, it only is called not "cache", and locks. At the editing beginning in shape there is an attempt to block object in a DB. If it is already blocked, the user receives the error report. W> it is so-called pessimistic locks. Happen still optimistic, but for simplicity yet we will not be about them. W> SQLite does not support lock at level of separate lines, only the table entirely. It is necessary or implement them in application, or to replace a DBMS. We admit in sqlite there would be pessimistic locks at level of rows of the table. Clearly as it helps with the scenario took object, changed and is returned on that place whence took. But how they help with a coordination of the data in different windows? We admit there is a window with the object list, double  the window of review of object in which there are buttons "Delete" opens and to "Edit". At pushing to "Edit Or"delete"logically to take lock but how other"windows"which work with basis only on reading receive the information on that that something exchanged and it is necessary to pull out the data anew? Clearly as it to do when edit windows modal, and after control resetting it is possible to re-read basis, and if they as in my case the non-modal?

7

Re: Display of lines of the table of basis in objects?

Hello, dave_2, you wrote: _> It is admissible in sqlite there were pessimistic locks at level of rows of the table. _> it is clear as it helps with the scenario took object, changed and is returned on that place whence took. _> but how they help with a coordination of the data in different windows? Here they help really a little. Locks at DB level are necessary when with basis some users independently work. I, when answered above, meant such scenario. And synchronization of the data in one copy of application before this data is written down in basis, is a care of the developer of application, that is yours. _> we admit there is a window with the object list, double  the review window _> object in which there are buttons "Delete" opens and to "Edit". _> At pushing to "Edit Or"delete"logically to take lock, _> but how other"windows"which work with basis only on reading receive _> the information on that that something exchanged and it is necessary to pull out the data anew? For example, windows can send each other notification messages. Well or to a primary window which will send all of them remaining. By the way, locks happen and on reading too so it is possible to use and them if it does not hinder other users.