Question about difference between text file and database

  • Thread starter Thread starter Gary
  • Start date Start date
G

Gary

Hi in a simple application that consists of a couple of user input
forms. I'm wondering what the difference is between using a database
technology and a plain text file?

I've been working on this program for a week or so now and its a hobby
project. I have never understood how to work with databases in visual
studio (although I have strung together a couple of Microsoft access
databases in the past, by trial and error.)

As I don't understand databases I've opted to store the information in
a simple text file. I am delimitting fields with semicolons and using a
fixed format, so for instance I know the name of the person is always
the fifth delimitted bit of data on each line. So to search for a
particular persons records, I have written a class that searches the
fifth bit of data on each line for a matching name. And returns the
results as an array.

I'm just about to add some kind of primary key functionality to my text
file by numbering each record. I'm going to check the text file for
it's last entrys primary key and increment this by one to use as the
next records primary key.

All appears to be working ok.

My question is, am i fundamentally missing some point here? Or is my
simple text file, just as good as a 'database' for my project?

Thanks,

Gary.
 
Hi,
Hi in a simple application that consists of a couple of user input
forms. I'm wondering what the difference is between using a database
technology and a plain text file?

I've been working on this program for a week or so now and its a hobby
project. I have never understood how to work with databases in visual
studio (although I have strung together a couple of Microsoft access
databases in the past, by trial and error.)

As I don't understand databases I've opted to store the information in
a simple text file. I am delimitting fields with semicolons and using a
fixed format, so for instance I know the name of the person is always
the fifth delimitted bit of data on each line. So to search for a
particular persons records, I have written a class that searches the
fifth bit of data on each line for a matching name. And returns the
results as an array.

I'm just about to add some kind of primary key functionality to my text
file by numbering each record. I'm going to check the text file for
it's last entrys primary key and increment this by one to use as the
next records primary key.

All appears to be working ok.

My question is, am i fundamentally missing some point here? Or is my
simple text file, just as good as a 'database' for my project?

Thanks,

Gary.

You should consider XML. They have all the advantages of a text file
(they are, in fact, text), but they are very well supported in .NET (no
need to worry about reading, parsing, validating...).

XML is often a very good choice for small projects where you don't want
to have a full blown database.

HTH.
Laurent
 
Thanks for that.

I haven't encountered XML before (short of knowing XML has something to
do with the code snippet technology.) I tried to have a play with it as
a starting point for learning more about it. I found an msdn article.
The article instructs me to add an xml scheme to the project. However I
dont have this as a new item option. I'm using C# express. Are xml
schema's not available in express? Is xml schema the thing I should be
looking at in view of your comments?

As a last resort i do have visual studio at home which I could install
at the office, but i'd rather stay with express on the office pc if
possible.

Thanks!

Gary.
Hi,
Hi in a simple application that consists of a couple of user input
forms. I'm wondering what the difference is between using a database
technology and a plain text file?

I've been working on this program for a week or so now and its a hobby
project. I have never understood how to work with databases in visual
studio (although I have strung together a couple of Microsoft access
databases in the past, by trial and error.)

As I don't understand databases I've opted to store the information in
a simple text file. I am delimitting fields with semicolons and using a
fixed format, so for instance I know the name of the person is always
the fifth delimitted bit of data on each line. So to search for a
particular persons records, I have written a class that searches the
fifth bit of data on each line for a matching name. And returns the
results as an array.

I'm just about to add some kind of primary key functionality to my text
file by numbering each record. I'm going to check the text file for
it's last entrys primary key and increment this by one to use as the
next records primary key.

All appears to be working ok.

My question is, am i fundamentally missing some point here? Or is my
simple text file, just as good as a 'database' for my project?

Thanks,

Gary.

You should consider XML. They have all the advantages of a text file
(they are, in fact, text), but they are very well supported in .NET (no
need to worry about reading, parsing, validating...).

XML is often a very good choice for small projects where you don't want
to have a full blown database.

HTH.
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Hi,
Thanks for that.

I haven't encountered XML before (short of knowing XML has something to
do with the code snippet technology.)

I am not sure what you mean with this. XML (eXtensible Markup Language)
is a text-based language, where you represent objects or structure
through hierarchies of tags. These tags can also have attributes, which
can be used to represent properties of objects. This is a very reductive
definition of XML, more information can be found here:

http://en.wikipedia.org/wiki/Xml
I tried to have a play with it as
a starting point for learning more about it. I found an msdn article.
The article instructs me to add an xml scheme to the project. However I
dont have this as a new item option. I'm using C# express. Are xml
schema's not available in express? Is xml schema the thing I should be
looking at in view of your comments?

XML schemas are not totally necessary to a XML file, especially not when
you are starting to learn it, but they can help later. A XML schema (XSD
file, or DTD file (but that's older and I wouldn't recommend it)) are
used to describe the structure of an XML file. Since XML is extensible,
you can define your own tags and attributes. Through the XSD file, you
describe how your XML file is organized (for example: The main node must
be named "MainTest"; the first child must be of type "HelloWorld";
"HelloWorld" may occur only 2 times in the hierarchy; etc...).

If you define a XSD file, then editors like Visual Studio help you with
data entry by showing you an intellisense box when you type, so you can
select the node or the attribute you want to add. It also helps you by
validating what you type, i.e. comparing it against the schema and
underlining what does not conform.

However, for a first try, I would recommend you forget schemas for the
moment. You can create an XML file in any text editor.
As a last resort i do have visual studio at home which I could install
at the office, but i'd rather stay with express on the office pc if
possible.

I am not familiar with Express, but I don't see why that shouldn't be
possible. My advice is to check the web for simple examples of XML
files, define your own data structure, and start coding ;-)
Thanks!

Gary.

Greetings,
Laurent
 
Back
Top