data structures versus data bases???

Brad Bollenbach bbollenbach at home.com
Sat Nov 10 19:56:04 EST 2001


[snip]

> In common usage, a data structure is something you make to put your
> data in.  A class, a list, a dictionary, anything you can put data in.

A database is precisely the same thing. You put data in it.

> A database is somebody else's data structure(s), possibly already full
> of data.  You can buy them from people like Oracle, or get free ones
> like Postgres, but they all share the property that they are _somebody
> else's box of stuff_.  If you want to use the data in a database, you

No, it's not always somebody else's "box of stuff" by any means. A database
can be something as simple as a .dat and its corresponding .idx file.

[snip]

Simply put (and referring to the most common cases), a database is a
relatively large (or, often very large), persistent (as in "written to
disk") set of data. It can be something as simple as a set of flat files
(that is, your normal .txt's, or the .dat's and .idx's mentioned
previously), or as is common is business programming, a "relational
database" where data is stored in tables; rows of fixed length data (not
/quite/ precise, but accurate enough for purposes of this discussion) with
corresponding fields in them. Think of an Excel spread sheet. As it turns
out, a .xls file can easily be considered a database.

A data structure on the other hand is all the bits and pieces used in your
program as variables (or constants) to store data in memory while your
program runs. As it turns out, data structures can also be persisted (that
is, written to disk), via modules like pickle, but that's hardly a common
characteristic among all "data structures". They're the nuts and bolts
things like lists, dictionaries, classes, sets, queues, linked lists, et.
al.

Hope that helps,

Brad





More information about the Python-list mailing list