?
Solved

ATL collection using database

Posted on 2001-07-12
9
Medium Priority
?
185 Views
Last Modified: 2006-11-17
Hi,
I have implemented a collection in ATL.
"People" is the collection "Man" is an item of the collection.

In the database i have a table People and so, each record in the table is a Man.
I use ADO to access my database.

And my ATL collection have to support multithread.

On each item of the collection, you can Set and Get properties.

The problem i have is on how i get the data of my items. I can't store the data directly in the "Man" object because if another client have changeed the name for instance, the state of my object will be incorrect for other clients.

So, i have to get the data in the database each time the client access a property of an item. And it disturbs me a lot because it implies each item to have a recordset, to go and get the data in the database.

So 70000 items --> 70000 recordsets, i think it is not acceptable.

So my question is, what is the current and efficient way to implement a collection that manages table of a database?

Thanks!




0
Comment
Question by:FMayis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 2

Expert Comment

by:missionImpossible
ID: 6277348
I don't know if I really got it, but you don't need to have one recordset per item. You can use one recordset per client. The recordset in your case should be a "Dynamic"-recordset type. This is a representation of a dynamic cursor, which shows every changes of other users on the fly. See also MSDN.

0
 
LVL 6

Expert Comment

by:snoegler
ID: 6280083
>> So my question is, what is the current and efficient way to implement a collection that manages table
of a database?

A database :)
Databases are specifically designed for handling this. By putting a 'container' around a database table, all benefits of a database are lost (as long as you want a generic container) (or you are going to re-implement SQL which is specifically designed for doing all time critical tasks within the highly optimized database engine).
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6280828
I agree wish snoeglar let the database be the main store of your collection - if you need to hand it out do a select * and generate your collection on that and pass it on - or you can pass out single items, subsets or the whole thing - if an item needs to check its state (dirtyness) then you can either check with a flag (eg timestamp of last update) or just get the whole thing.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Expert Comment

by:snoegler
ID: 6280844
>> as long as you want a generic container
i meant:
>> as long as you want a simple container
0
 

Author Comment

by:FMayis
ID: 6284868
Hi,
I do agree, the database is the main store of the collection.

For the moment i did a select * and then use the generated recordset to implement my collection.

and doing a SELECT * implies loading in memeory lot of things not needed. If a user works with an item and i have some thousand in the database, then lot of memories are lost for nothing.

So,what is the best compromise(performance time, memory size) between loading all, or making a request on each access to data of an item property.

0
 
LVL 2

Accepted Solution

by:
missionImpossible earned 800 total points
ID: 6284908
1. if you need all data of a row (select *), to get it once is quite more performant, as to access the data in multiple access.
But sometimes it could be clever to fetch data lazy: F.ex if your user needs only in 5% of all use cases all the data, you can fetch this data only if he really needs it. in 95% of the cases you can get only the  data he needs and your app will be more performant. It depends on what the user needs.

2. if the user don't needs to access all rows (at the same time), filter your select, to get only one or few rows of data.
0
 

Author Comment

by:FMayis
ID: 6285255
The collection will be used like follows

for i = 1 to Count
    item=col.GetItem(i)
    item.GetName //or anyother property
next

or

item = col.GetItem("Name")
//and then get all properties of the item


I think that getting data when needs will be more performant.

0
 
LVL 6

Expert Comment

by:snoegler
ID: 6285262
What about a collection like this:

MyColl.Init "SELECT * from customer";
For Each Elem in MyColl
  Print Elem("Name"), Elem("Street"), Elem("Zip")
Next

This reminds me of something :)
0
 

Author Comment

by:FMayis
ID: 6368723
Sorry for elapsed time!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question