------------------------------------------------ On Fri, 19 Sep 2003 09:51:20 -0500, David Gilden <[EMAIL PROTECTED]> wrote:
> Hello, > > I am taking over a site that was on a M$ server and redoing the Guest book and form > pages > in PERL. Question I have is the design of database. > > I have the following fields: Name varchar(80) > Date date > email varchar(100) > comments varchar(100) > > Should I be writing the comments (text of ~600 characters) or a 'path' > to a file that holds the text. If I do the later and I have say 20 entries per > page. > That is 20 disk reads to create the page.html. Am I on the right `path` :) > Unless this is running on a 386 (even maybe still then) you should just plop the comments into the table as a 'text' field type. Then only select the field when it is necessary to display, for instance if you are building a table of contents or something you wouldn't select it. I would avoid completely the storing of the text to disk unless you are talking about *a lot* of text and you aren't even close to that, there are issues with permissions, locking, etc. that you don't want to have to handle that the database will for you. The approach you suggest works well for larger size files or in many cases binary files where they can be served directly without reading in and printing (aka image files on a web server where they are linked to rather than printed by the script). As a side note *always* include a unique id and make it a primary key, this will speed up accessing single records of the database and make edits simpler by always being sure you are editing the correct record. Usually I use a form of 'int' small is often sufficient (32,000+ rows) and make it auto-incrementing to avoid any hassles with that. Some other fields I usually add, include a 'status' to allow you to turn on and off records without deleting them (or to implement a simple approval system, aka a user enters a comment and you want to approve it before it gets put on your site), a date created which you have, and a last updated so I know when my editor last touched the record. And if there is the potential for replies you may want to add a 'parent' id field that will allow threading.... HTH, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]