View Single Post
Old 02-17-2006, 09:41 AM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,713
redhead is on a distinguished road
One thing I've noticed when trying out these types, is, when using type TEXT fields as opposed to BLOB, you can make case sensitive searches, BLOB dosn't support that.
From your layout, I recon a table design similar to this might work:
Code:
CREATE TABLE location (
    id INT(11) DEFAULT '0' NOT NULL auto_increment,
    name VARCHAR (20),
    street VARCHAR (25),
    number INT(6),
    town VARCHAR (25),
    zipcode INT(6),
    atmosphere BLOB,
    UNIQE id,
    PRIMARY KEY id
    );
CREATE TABLE cabin (
    id INT(11) DEFAULT '0' NOT NULL auto_increment,
    name VARCHAR (20) NOT NULL,
    size INT(8),               # squarefeet of cabin
    location_id INT(11),
    bath INT(1) DEFAULT '0' NOT NULL, # does it have a bath (1: yes, 0: no)
    water INT(1) DEFAULT '0' NOT NULL, # does it have running water (1: yes, 0: no)
    heat INT(1) DEFAULT '0' NOT NULL, # does it have heat (1: yes, 0: no)
    electric INT(1) DEFAULT '0' NOT NULL, # does it have electricity (1: yes, 0: no)
    other BLOB,
    UNIQE id,
    PRIMARY KEY id,
    FOREIGN KEY (location_id) REFERENCES location
    );
CREATE TABLE cabin_pics (
    id INT (11) DEFAULT '0' NOT NULL auto_increment,
    cabin_id INT(11) NOT NULL,
    name VARCHAR(11) NOT NULL,
    UNIQE id,
    PRIMARY KEY id,
    FOREIGN KEY (cabin_id) REFERENCES cabin
    ); 
CREATE TABLE beds (
    id INT (11) DEFAULT '0' NOT NULL auto_increment,
    cabin_id INT(11) NOT NULL,
    UNIQE id,
    PRIMARY KEY id,
    FOREIGN KEY (cabin_id) REFERENCES cabin
    ); 
CREATE TABLE feature (
    id INT (11) DEFAULT '0' NOT NULL auto_increment,
    cabin_id INT(11) NOT NULL,
    description BLOB,
    UNIQE id,
    PRIMARY KEY id,
    FOREIGN KEY (cabin_id) REFERENCES cabin
    );
Now your Electric, bathroom, heat, water choices I guess are just true/false values, since they seem to just be some info on wether the cabin has got it or not.. So these can be simple check boxes, instead of text boxes..
So you store a '1' when they have it, and a '0' when they dont.

This layout provide you with some scalability, you can have any number of pictures assigned to a cabin, just queue something like "SELECT * FROM cabin_pics WHERE cabin_id = <some id>"
And you can all sorts of beds assigned to a cabin this way, aswell as any number of cabins located at the same location.. etc.

But then again, this is just a suggestion... I'm sure alot of the users here can come up with alot of other solutions.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote