473,746 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serializing data vs Storing it in a seperate table

What would give better performance, serializing a multidimensiona l 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 entries with the entry
in the other table?

Having a separate table would result in two queries instead of one, but
you wouldn't have to deal with the overhead of serializing and
unserializing data.

-- Kyle
Jun 12 '06 #1
6 3181
Kyle Teague wrote:
What would give better performance, serializing a multidimensiona l 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 entries with the entry
in the other table?

Having a separate table would result in two queries instead of one, but
you wouldn't have to deal with the overhead of serializing and
unserializing data.

-- Kyle


That depends. Is the multidimensiona l array a single entity - or is it a
collection of entities?

Do some research on "database normalization". It's almost never a good idea to
store multiple entities in a single field in a RDB.

BTW you can still do it with one query by joining tables.

One other thing - this isn't a PHP question - you should be asking in a group
related to your database, such as comp.databases. mysql.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 13 '06 #2
Jerry Stuckle wrote:
Kyle Teague wrote:
What would give better performance, serializing a multidimensiona l 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 entries with the entry
in the other table?


That depends. Is the multidimensiona l array a single entity - or is it a
collection of entities?

Do some research on "database normalization". It's almost never a good
idea to store multiple entities in a single field in a RDB.

BTW you can still do it with one query by joining tables.

One other thing - this isn't a PHP question - you should be asking in a
group related to your database, such as comp.databases. mysql.


I don't think its OT. It really depends how big the array is and whether you
need all of it in memory every time you access it. If you only need a
specific element, I was surprised to find that even for quite small sets of
values the database was faster.

Build a test rig and try it out for yourself.

HTH

C.
Jun 16 '06 #3
Colin McKinnon wrote:
Jerry Stuckle wrote:

Kyle Teague wrote:
What would give better performance, serializing a multidimensiona l 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 entries with the entry
in the other table?


That depends. Is the multidimensiona l array a single entity - or is it a
collection of entities?

Do some research on "database normalization". It's almost never a good
idea to store multiple entities in a single field in a RDB.

BTW you can still do it with one query by joining tables.

One other thing - this isn't a PHP question - you should be asking in a
group related to your database, such as comp.databases. mysql.

I don't think its OT. It really depends how big the array is and whether you
need all of it in memory every time you access it. If you only need a
specific element, I was surprised to find that even for quite small sets of
values the database was faster.

Build a test rig and try it out for yourself.

HTH

C.


Colin,

Look at the question again. He's asking about the method of storing data in a
database (database structure), not array handling.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 17 '06 #4
Jerry Stuckle (js*******@attg lobal.net) wrote:
: Colin McKinnon wrote:
: > Jerry Stuckle wrote:
: >
: >
: >>Kyle Teague wrote:
: >>
: >>>What would give better performance, serializing a multidimensiona l 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 entries with the entry
: >>>in the other table?
: >>>
: >>
: >>That depends. Is the multidimensiona l array a single entity - or is it a
: >>collection of entities?
: >>
: >>Do some research on "database normalization". It's almost never a good
: >>idea to store multiple entities in a single field in a RDB.
: >>
: >>BTW you can still do it with one query by joining tables.
: >>
: >>One other thing - this isn't a PHP question - you should be asking in a
: >>group related to your database, such as comp.databases. mysql.
: >>
: >
: >
: > I don't think its OT. It really depends how big the array is and whether you
: > need all of it in memory every time you access it. If you only need a
: > specific element, I was surprised to find that even for quite small sets of
: > values the database was faster.
: >
: > Build a test rig and try it out for yourself.
: >
: > HTH
: >
: > C.

: Colin,

: Look at the question again. He's asking about the method of storing data in a
: database (database structure), not array handling.

Look at the question again. He's asking about "serializin g a
multidimensiona l array", which is php array handling.

In other words, he is asking whether it is better to implement his data
structure in php and use the database just as a blob-like storage medium,
or is it better to implement his data structure in the database and use
php just as an access method to get at the (already structured) data.

I would normally tend to towards defining the correct database structure
to hold the data. It will be more flexible in the long run, and you still
have the option of loading the data into a php data structure if you
really need to do that for speed in some situations.

Jun 17 '06 #5
Kyle Teague wrote:
What would give better performance, serializing a multidimensiona l 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 entries with the entry
in the other table?

<snip>

That depends. If you store multi-dimensional array in a single
field by serializing, querying data (if based on the values present in
the array) will be difficult; so in that case, storing them in tables
will be a better choice.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jun 18 '06 #6
Malcolm Dew-Jones wrote:
Jerry Stuckle (js*******@attg lobal.net) wrote:
: Colin McKinnon wrote:
: > Jerry Stuckle wrote:
: >
: >
: >>Kyle Teague wrote:
: >>
: >>>What would give better performance, serializing a multidimensiona l 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 entries with the entry
: >>>in the other table?
: >>>
: >>
: >>That depends. Is the multidimensiona l array a single entity - or is it a
: >>collection of entities?
: >>
: >>Do some research on "database normalization". It's almost never a good
: >>idea to store multiple entities in a single field in a RDB.
: >>
: >>BTW you can still do it with one query by joining tables.
: >>
: >>One other thing - this isn't a PHP question - you should be asking in a
: >>group related to your database, such as comp.databases. mysql.
: >>
: >
: >
: > I don't think its OT. It really depends how big the array is and whether you
: > need all of it in memory every time you access it. If you only need a
: > specific element, I was surprised to find that even for quite small sets of
: > values the database was faster.
: >
: > Build a test rig and try it out for yourself.
: >
: > HTH
: >
: > C.

: Colin,

: Look at the question again. He's asking about the method of storing data in a
: database (database structure), not array handling.

Look at the question again. He's asking about "serializin g a
multidimensiona l array", which is php array handling.

Yes - but only as it affects how to store it in the database. Without the
database the serialization is meaningless.
In other words, he is asking whether it is better to implement his data
structure in php and use the database just as a blob-like storage medium,
or is it better to implement his data structure in the database and use
php just as an access method to get at the (already structured) data.

Which is why he needs to be asking in the database newsgroup.
I would normally tend to towards defining the correct database structure
to hold the data. It will be more flexible in the long run, and you still
have the option of loading the data into a php data structure if you
really need to do that for speed in some situations.


It depends entirely on how he's going to use the data. Does he need to retrieve
all the data all the time? Or just bits and pieces of it?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 18 '06 #7

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

Similar topics

16
3033
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
10
8306
by: copx | last post by:
I want to save a struct to disk.... as plain text. At the moment I do it with a function that just writes the data using fprintf. I mean like this: fprintf(fp, "%d %d", my_struct.a, my_struct.b) This way I have to write another "serializing" function for every new kind of struct I want to write, though. Is there a way to write functions that can write/read any struct to/from plain text format in a portable way?
2
3519
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: + More ways to contact me __________________________________________________________________
1
1315
by: Martin Widmer | last post by:
Hi guys I am wondering what is a proper way to persistently store objects into SQL-Server. I see four possible ways: 1.) Serialize to XML and then store the XML in the SQL server 2.) Write a new serializer that serializes the object by storing each attribute value into a matching field in an SQL server table while performing data type mapping and possibly compression etc... 3.) For each class write a proxy class who's objects are...
0
365
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 entries with the entry in the other table? Having a separate table would result in two queries instead of one, but you wouldn't have to deal with the overhead of serializing and unserializing data. -- Kyle
47
3111
by: Max | last post by:
Due to the behaviour of a particular COM object, I need to ensure that a request for a particular ASP page is finalized before another request for the page is processed. Does IIS have a way to ensure that subsequent requests will be queued until the current request is completed? If not, can IIS be configured to use seperate processes to satisfy requests for a nominated ASP page? Thanks in advance.
3
3275
by: Chris | last post by:
All I am cross-posting, as I'm not sure if this is an issue for the data layer or the application layer. If this is unacceptable, can someone let me know so that I don't do this in future. I'm using ASP .NET, framework version 1 and SQL Server 2000. I have an ASPX page with a form for customers to register. When they click on the "Proceed" button, they are shown a preview page of the data that they
4
1474
by: buggtb | last post by:
This may be a blindingly obvious question but I am working on a little project and I'm relatively new to PHP. What I am wanting to do it load a load of data from an array into a table generated by php.... simple enough. Anyway our table is huge and when you scroll along you loose your row headings which is annoying to say the least. So I created a seperate frame to act as a 2nd column in our page which I was hoping to load the array names...
1
1803
by: webcm123 | last post by:
I'm looking for a good method of securing ratings. Cookies lock isn't sufficient. In addition to cookies I would need something else. I'm introducing some ways. -= Storing rates inside seperate tables =- Seperate tables (artrates, filerates, imgrates) will contain: ID of item | rate | user | IP 1 rate = 1 record. Field USER will filled if only registered users can
0
8975
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8801
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9516
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9351
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9286
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9219
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8229
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6774
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.