>----- Original Message -----
>From: "Travis Gant" <[EMAIL PROTECTED]>
>To: "MySQL Mailing List" <[EMAIL PROTECTED]>
>Sent: Thursday, March 08, 2001 5:57
>Subject: MySQL backend for website.


>Hi, new to the list.
>I'm trying to write a MySQL backend for my website to archive/search news
stories, and other >things I have on my site,
http://slardy.yi.org/nu-vision/ .  I know that my site is pretty small and I
>could probably go with using something else but I want to learn the basics
of MySQL, I've been >fooling around with it allot lately and I want to start
integrating it with my site while it is young.  What >I've done so far is
basically plan out how many tables I will need, etc.  I plan on using one
database >file with 6 tables, each table will either be for user data or
page content, I have different types of >sections so I need different tables
for each.  I'm going to write the front-end software in Perl, which I
>already have experience with and hope to one day re-write the site using
PHP but still retain the >database data, I see no problem with this.  I have
two things I need help with.

>1) I want to keep a time/date for each piece of news, I know MySQL has a
few time and date >types.  Would it be easier to use the timestamp type and
then convert it to a human readable >time/date in Perl or keep separate time
and date variables for each row.  Is the timestamp type like >the usual
format, seconds since 1970?

I think you need to re-read the sections dealing with date and time.  In
short timestamp is not unix epoch time and is human readable.  It is used to
record the current time and date each time you do an insert or update.  If
you don't want you date column updating each time you modify or insert, use
a different "date" type column.  MySQL's date & time functions can also be
used to format the display or your date & time.

>2) When I attempt to create the table for news I really hit a brick wall.
This is what I am attempting >to use:
>    create table news (
>    poster varchar(50) not null,
>    email varchar(100) not null,
>    topic varchar(200) not null,
>    story text(1000) not null primary key);

>I get an error on the line "story text(1000) not null primary key);" what
would be the proper syntax?  >Also by defining story as a larger size would
that use more space up on the hard drive or does that >just increase the
possible number or characters in the story, not set aside that many bytes.

1.  Again, you need to re-read the appropriate section of the manual.
Quoting the first few words of the 2nd para under 7.3.4.2 "The four TEXT
types TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT ..."

2.  For some reason, in the past, I've always had trouble getting your last
line to work.  Change it to
     story text not null,
     primary key(story));
and you shouldn't find any problems

3. TEXT storage requirements are in 7.3.1.3

4. Why do you want a TEXT column type set as the primary key?  Doesn't make
sense to me under any circumstances.  Even your topic column would make a
better primary key but still not that good as it is possible that one user
can enter the same topic as someone else.


>Thanks very much.  If anyone could suggest a good website for this kind of
thing, other than the >MySQL homepage, or even a good book.  Thanks very
much.

>Travis Gant


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to