473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Serializing vs. persisting to database?

When does serializing objects make more sense than persisting them to a
database? I'm new to object serialization, and I'm trying to get a feel for
when to use it.

Here is an example: I'm writing an accounting application. I have a chart of
accounts in the form of a containment hierarchy. A GeneralLedger contains a
number of Accounts, and each of these Accounts can contain a Aubledger,
which contains its own Accounts, and so on. The chart of accounts is loaded
when the app initializes and stays in memory until the app terminates. I
also have lots of transactions, which are read from the database and mapped
into Transaction objects as needed, using the chart of accounts to filter
the selection.

For a moment, disregard the database design issues involved. Does it make
sense to serialize a containment hierarchy like the chart of accounts,
rather than persisting it to the database? Is that how one would normally
use object serialization?

Thanks in advance!

--
Dave Veeneman
Chicago
Nov 15 '05 #1
4 3597
"Dave Veeneman" <da****@nospam.com> wrote in message
news:O8*************@tk2msftngp13.phx.gbl...
When does serializing objects make more sense than persisting them to a
database? I'm new to object serialization, and I'm trying to get a feel for when to use it.

Here is an example: I'm writing an accounting application. I have a chart of accounts in the form of a containment hierarchy. A GeneralLedger contains a number of Accounts, and each of these Accounts can contain a Aubledger,
which contains its own Accounts, and so on. The chart of accounts is loaded when the app initializes and stays in memory until the app terminates. I
also have lots of transactions, which are read from the database and mapped into Transaction objects as needed, using the chart of accounts to filter
the selection.

For a moment, disregard the database design issues involved. Does it make
sense to serialize a containment hierarchy like the chart of accounts,
rather than persisting it to the database? Is that how one would normally
use object serialization?

Thanks in advance!

--
Dave Veeneman
Chicago


I think you'll find that the biggest factors in your decision will be what
you want to -do- with the data, and not so much the structure.

If you're answering "Yes" to the following questions, it should point you in
the direction of using a database:

Is the data going to be shared among multiple users?
Might they access the data concurrently?
Do you want robust searching/filtering capabilities?
Are you going to be dealing with large numbers of records that may require
data paging?
Do you want to easily export your data to different formats?
Do you think your data models might change occasionally?
Is your data relational in nature, and do you want to leverage that
functionality in your code?

Erik
Nov 15 '05 #2
Hi Dave!
Use the DB to store your physical data i.e. the numbers and
transactions and you can (if you wish) serialize your objects to a
file. However, this object hierarchy is created somewhere, isn't it,
and can't this process be replicated at startup? Serializing an object
to some stream (file, network etc) will let you put the object with
all it's attributes and values in a binary file. You must retrieve
your objects in the same order as they are stored to the file.

- Peder -
"Dave Veeneman" <da****@nospam.com> wrote in message news:<O8*************@tk2msftngp13.phx.gbl>...
When does serializing objects make more sense than persisting them to a
database? I'm new to object serialization, and I'm trying to get a feel for
when to use it.

Here is an example: I'm writing an accounting application. I have a chart of
accounts in the form of a containment hierarchy. A GeneralLedger contains a
number of Accounts, and each of these Accounts can contain a Aubledger,
which contains its own Accounts, and so on. The chart of accounts is loaded
when the app initializes and stays in memory until the app terminates. I
also have lots of transactions, which are read from the database and mapped
into Transaction objects as needed, using the chart of accounts to filter
the selection.

For a moment, disregard the database design issues involved. Does it make
sense to serialize a containment hierarchy like the chart of accounts,
rather than persisting it to the database? Is that how one would normally
use object serialization?

Thanks in advance!

Nov 15 '05 #3
Dave,

I would put a database underneath all of this. There are just too
many occaisions where I find having a SQL underbelly makes the most
sense over the life of an application. I like XML for certain kinds
of tasks, but not as the basic storage form for all of my
application's data.

Here's a prediction: your posting is going to start a lengthy and
lively debate!

Les Matheson
Integral Concepts, Inc.
http://www.ivsds.com

"Reality is that which does not go away when you stop believing in
it."
- Philip K. Dick

"Dave Veeneman" <da****@nospam.com> wrote in message news:<O8*************@tk2msftngp13.phx.gbl>...
When does serializing objects make more sense than persisting them to a
database? I'm new to object serialization, and I'm trying to get a feel for
when to use it.

Here is an example: I'm writing an accounting application. I have a chart of
accounts in the form of a containment hierarchy. A GeneralLedger contains a
number of Accounts, and each of these Accounts can contain a Aubledger,
which contains its own Accounts, and so on. The chart of accounts is loaded
when the app initializes and stays in memory until the app terminates. I
also have lots of transactions, which are read from the database and mapped
into Transaction objects as needed, using the chart of accounts to filter
the selection.

For a moment, disregard the database design issues involved. Does it make
sense to serialize a containment hierarchy like the chart of accounts,
rather than persisting it to the database? Is that how one would normally
use object serialization?

Thanks in advance!

Nov 15 '05 #4
Dave,

I rarely see a need for serialization, but on occasion it comes in handy.
And sometimes it's even handy to persist an object in a DB using
serialization!

For example, I have an application where the user fills out an extensive
multi-page form of query specifications, which varies depending on the
report or export being set up. Out of potentially hundreds of data points,
only 2 or 3 are relevant for searching / filtering / sorting in the DB, so
those items are replicated in table fields. Other than that the entire
object is binary serialized into an image field in SQL Server.

The advantage is that any type of query (for various kinds of reports and
exports) can be stored and recalled, and I don't have to worry about the
details or provide a different table schema for each type of query or use
some other kludge. They all go into the same Queries table, which has a
QueryTypeID and the BLOB containing the query specification object (which is
just a SortedList of HashTables of strings).

--Bob

"Dave Veeneman" <da****@nospam.com> wrote in message
news:O8*************@tk2msftngp13.phx.gbl...
When does serializing objects make more sense than persisting them to a
database? I'm new to object serialization, and I'm trying to get a feel for when to use it.

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Citoyen du Monde | last post by:
Trying to get some ideas on a simple javascript project (to teach myself the language). I want to develop a client-side vocabulary practice application that would allow users to enter their own...
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
1
by: lim | last post by:
What is the possible error that occurs when the Page_load event is not triggered during execution. In my page there's some basic server control. Is there any loops holes?
2
by: John Hoge | last post by:
A common problem in database updates in the maintenece of "domain tables". For example, a product database has an option for color. When entering the specifications for a new product, a domain...
19
by: Siobhan | last post by:
Hi What is the recommended way to store a user's database credentials across the pages of a web application so that each time the database is accessed the system doesn't have to ask them for their...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
6
by: Kyle Teague | last post by:
What would give better performance, serializing a multidimensional array and storing it in a single entry in a table or storing each element of the array in a separate table and associating the...
0
by: freddie | last post by:
Hi, I am adding the data binding feature to the list view control. I am bale to populate the column collection dynamically from the datasource. I would like to allow the user to remove or add any...
0
ADezii
by: ADezii | last post by:
Most Access Users realize that Recordsets, being virtual representations of a Query, Table, or SQL Statement, exist only in our PC's memory. They, and the data they contain, literally exist at one...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.