Author Topic: First MySQL Query.  (Read 382 times)

0 Members and 1 Guest are viewing this topic.

Offline Ruud HermansTopic starter

  • Irregular
  • Posts: 23
    • View Profile
First MySQL Query.
« on: July 01, 2009, 09:27:47 AM »
OK, just wrote my first MySQL Query to set up some tables in a database. Could some on look over it if possible.

The parts I am worried about most are these (image will hold a thumbnail).

date DATE()
eatable ENUM ('yes', 'no', 'partly', 'poison')
comments TEXT()
image BLOB()

Code: [Select]
CREATE TABLE address (id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) NOT NULL, password VARCHAR(30) NOT NULL, email VARCHAR(30), location VARCHAR(30) NOT NULL, date DATE());

CREATE TABLE address (id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(200), latinname VARCHAR(200), date DATE(), location VARCHAR(255), eatable ENUM ('yes', 'no', 'partly', 'poison'), comments TEXT(), image BLOB());

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,256
    • View Profile
Re: First MySQL Query.
« Reply #1 on: July 01, 2009, 09:39:45 AM »
Its generally considered a better option to let your filesystem store images. Simply store the path to the file within your database.

Offline Ruud HermansTopic starter

  • Irregular
  • Posts: 23
    • View Profile
Re: First MySQL Query.
« Reply #2 on: July 01, 2009, 09:52:28 AM »
Its generally considered a better option to let your filesystem store images. Simply store the path to the file within your database.
How would I exactly do that if the file is on a server reffer to the URL or to the path?

What would it lool like in the query then, image VARCHAR(100)?

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,444
  • Gender: Male
    • View Profile
Re: First MySQL Query.
« Reply #3 on: July 01, 2009, 09:12:48 PM »
You'd store a relative pathname to the image itself.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.