473,511 Members | 14,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql vs. flatfiles

I have been using flat files for a while but thought I should learn
mysql. There are two things I dont like about mysql compared to using
flatfiles. They are:

1) When creating a table why do I need to define the type of data and
length so strictly, i,e int , varchar etc? Can I make a flexible table
with data of any type and length?

2) When creating a record I am using autoincrement ID. This works
great except when I delete a record it leaves a "hole" in the table.
How can I set it up to work like a flatfile where all records shift
"up" when one is deleted?

Any good tutorials that cover this?

Thanks,

Jul 17 '05 #1
5 2374

On 6-Jun-2005, el*************@yahoo.com wrote:
1) When creating a table why do I need to define the type of data and
length so strictly, i,e int , varchar etc?
it improves calculation, data storage and indexing for mysql to know what
data type is contained in a column.
Can I make a flexible table
with data of any type and length?
check out the blob data types.

2) When creating a record I am using autoincrement ID. This works
great except when I delete a record it leaves a "hole" in the table.
How can I set it up to work like a flatfile where all records shift
"up" when one is deleted?


There is no 'hole' in the table, only a missing number in the sequence. If
you really need to you can resequence a table but it's better to stop
thinking in terms of flat files and take advantage of the features of tables
and relations. For example you can retrieve the records from a table in
sequence by the auto-increment field, then count them as you retrieve them.
If all you want is the count, you can do that with a "select count()..."

The only way to close up a hole in a flat file is to rewrite all the records
from the hold forward, that's not practical in the case of a large number of
records. With a database, the 'cost' of deleting a row is usually minimal
because the records do not need to be stored sequentially.
--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #2
el*************@yahoo.com wrote:
2) When creating a record I am using autoincrement ID. This works
great except when I delete a record it leaves a "hole" in the table.
How can I set it up to work like a flatfile where all records shift
"up" when one is deleted?


Tom has already explained this rather well, but a short sidenote on
the autoincrement is that there is a reason why it leaves "holes" (in
the sequence). Have a look at:
http://dev.mysql.com/doc/mysql/en/ex...increment.html

If you specify a column as auto_increment, and then reuse the index,
how can you assure that each row has a unique identity? If you don't
need unique identities, just don't use auto_increment ;-)

/Marcin
Jul 17 '05 #3
Following on from 's message. . .
I have been using flat files for a while but thought I should learn
mysql. There are two things I dont like about mysql compared to using
flatfiles. They are: * Go with MySQL (almost) every time
* The documentation is clear and extensive
* Installation and integration is a doddle
* myadmin takes the hassle out of learning all the DDL stuff
* You are bound to need database features sooner rather than later so
bite the bullet - the learning curve is not difficult.
* Your questions will soon be answered when you get more familiar
* Flat files have lots of overheads - both computationally and hassle of
use. (Even a log file such as an audit trail, if it is to be analysed,
is probably better as a table.) - Don't even mention multi-user
aspects.


1) When creating a table why do I need to define the type of data and
length so strictly, i,e int , varchar etc? Can I make a flexible table
with data of any type and length?

2) When creating a record I am using autoincrement ID. This works
great except when I delete a record it leaves a "hole" in the table.
How can I set it up to work like a flatfile where all records shift
"up" when one is deleted?

Any good tutorials that cover this?

Thanks,


--
PETER FOX Not the same since the poster business went to the wall
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Jul 17 '05 #4
"Tom Thackrey" <us***********@nospam.com> wrote in message
news:0_***************@newssvr21.news.prodigy.com. ..

On 6-Jun-2005, el*************@yahoo.com wrote:
1) When creating a table why do I need to define the type of data and
length so strictly, i,e int , varchar etc?


it improves calculation, data storage and indexing for mysql to know what
data type is contained in a column.
Can I make a flexible table
with data of any type and length?


check out the blob data types.


Ugh - that would be a mess of a table.

Usually, when I need that sort of flexibility, I use a VARCHAR.

2) When creating a record I am using autoincrement ID. This works
great except when I delete a record it leaves a "hole" in the table.
How can I set it up to work like a flatfile where all records shift
"up" when one is deleted?


There is no 'hole' in the table, only a missing number in the sequence. If
you really need to you can resequence a table but it's better to stop
thinking in terms of flat files and take advantage of the features of
tables
and relations.


The relational aspect is the main reason I use ID's like that - it's
something that is used internally, and rarely seen by the end user. So it
doesn't really matter if it's not perfectly sequential.
Jul 17 '05 #5
>I have been using flat files for a while but thought I should learn
mysql. There are two things I dont like about mysql compared to using
flatfiles. They are:

1) When creating a table why do I need to define the type of data and
length so strictly, i,e int , varchar etc? Can I make a flexible table
with data of any type and length?
Stating the type of data and length can let the database help you
in validating data, for example, the inventory count of widgets
on hand is unlikely to be 'Green' and dates can be stored more
efficiently if the database knows it's a date.

Look at the 'blob' types if you really want arbitrary data (some people
put raw binary image files into blob fields).
2) When creating a record I am using autoincrement ID. This works
great except when I delete a record it leaves a "hole" in the table.
How can I set it up to work like a flatfile where all records shift
"up" when one is deleted?


Are you sure you want it to work that way? Imagine the havoc if your
bank account number changed every time someone who had an account before
you did closed theirs?

I suggest that you use a field you want to sort by (for example, date/time
entered) and assign the numbers on the fly when you retrieve the data.

Gordon L. Burditt
Jul 17 '05 #6

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

Similar topics

2
10261
by: francescomoi | last post by:
Hi. I'm trying to build 'MySQL-python-1.2.0' on my Linux FC2: ---------------------------------- # export PATH=$PATH:/usr/local/mysql/bin/ # export mysqlclient=mysqlclient_r # python setup.py...
0
3293
by: Randell D. | last post by:
Folks, I have installed MySQL v4 (client, server and development rpm's). I've tried and failed to use the recommended mysqladmin to set a root password after the installation (I have another post...
4
1305
by: mikey | last post by:
Hi all, I'm having great problems trying to install the latest MySQl RPM package onto my Red Hat Linux OS. There is already MySQL v 3.0 pre-installed with the RH Linux distribution disk but I...
0
3925
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
11
1820
by: weissborn | last post by:
I have an application I have written in MS Access 2002. It is a very basic inventory system for keeping track of information about our Unix(solaris to be specific) servers. Other admins may want...
2
2889
by: trihanhcie | last post by:
I m currently working on a Unix server with a fedora 3 as an os My current version of mysql is 3.23.58. I'd like to upgrade the version to 5.0.18. After downloading from MYSQL.COM the package on...
1
3193
by: manish deshpande | last post by:
Hi, When i'm installing MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm by the following command: rpm -i MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm the following error is being shown: ...
3
8792
by: menzies | last post by:
Hi, I"m new to this forum, but I have been trying all day to install DBD::mysql onto my Intel MacBook. I've read lots of forums pages and none have gotten me to a successful 'make test' or a...
13
2280
by: Richard Brooks | last post by:
Does anyone here open a second MySQL database and use that as a straight IDX type file that points to the record number in the main database, for speed's sake? Some time ago I'd set up a...
0
7252
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
7371
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
7432
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...
1
7093
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...
1
5077
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...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1583
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 ...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.