So I’ve done a lot with databases but haven’t ever really worked on a website where efficiency has to be managed well due to a large amount of traffic. The idea is pretty simple when you get to reading the structure, and I’m willing to answer any questions about any tables.
In my previous database designs I found myself incorporating a lot of things that really should’ve had their own tables into other tables. For example I had an articles table that had a tags field with a comma-seperated string for their tags, and no definition of tags in their own table. Which I came to pay for in the long run when I wanted to make the tags part of the site more in-depth I couldn’t keep putting massive strain on the database. So this design I tried to keep data seperate from one another but included what I thought was necessary, there are comments at the end of each table to indicate their primary function.
My biggest concerns are indexes, foreign keys, and MyISAM vs InnoDB, I’ve been doing a lot of reading on how one is better for a lot more select queries, and another is better for more write transactions. On the premise of the site I would have to say the amount of viewing (select queries) to writing(update/inserts) would be 2:1 perhaps, so twice as many selects to writes.
However I believe only InnoDB supports foreign keys, so if anyone seems that they are required then that will settle that component of it.
I appreciate you guys taking the time to look at this lengthy post and table structure and giving feedback.
CREATE TABLE `theaters` (
`theaterID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`companyID` INT( 11 ) NULL ,
`name` VARCHAR( 100 ) NOT NULL ,
`description` VARCHAR( 255 ) NULL,
`mainImage` VARCHAR( 150) NULL,
`address` VARCHAR( 100 ) NOT NULL ,
`city` VARCHAR( 50 ) NOT NULL ,
`state` VARCHAR( 2 ) NOT NULL ,
`phone` INT( 11 ) NULL COMMENT 'Raw digits of a phone number, dashes can be added through PHP.'
) ENGINE = INNODB
COMMENT = 'Sole purpose is to hold the main attributes of a movie theater.';
CREATE TABLE `companies` (
`companyID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 50 ) NOT NULL ,
`description` TEXT NULL
) ENGINE = INNODB
COMMENT = 'Used to store each company''s name and ID for reference of theaters.';
CREATE TABLE `theater_company` (
`theaterID` INT( 11 ) NOT NULL ,
`companyID` INT( 11 ) NOT NULL
) ENGINE = INNODB
COMMENT = 'Stores the relationship of theaters to companies. (1 to Many)';
CREATE TABLE `theater_pricing` (
`theaterID` INT( 11 ) NOT NULL ,
`adult` VARCHAR( 5 ) NULL ,
`senior` VARCHAR( 5 ) NULL ,
`child` VARCHAR( 5 ) NULL ,
`3d` VARCHAR( 5 ) NULL ,
`matinee` VARCHAR( 5 ) NULL
) ENGINE = INNODB
COMMENT = 'Prices will be stored in a 10.75 format ($10.75).';
CREATE TABLE `theater_reviews` (
`reviewID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`theaterID` INT( 11 ) NOT NULL ,
`overall` FLOAT NOT NULL COMMENT 'Averages the other ratings',
`reviewContent` VARCHAR( 255 ) NOT NULL COMMENT 'Since it''s mostly rating based, this is a small input field for additional comments.' ,
`picQuality` TINYINT( 1 ) NULL ,
`audioQuality` TINYINT( 1 ) NULL ,
`priceQuality` TINYINT( 1 ) NULL ,
`staffQuality` TINYINT( 1 ) NULL ,
`restroomQuality` TINYINT( 1 ) NULL ,
`stickyFloor` TINYINT( 1 ) NULL ,
`seatingQuality` TINYINT( 1 ) NULL ,
`concessionSelection` TINYINT( 1 ) NULL ,
`concessionPrices` TINYINT( 1 ) NULL ,
`visitAgain` TINYINT( 1 ) NULL COMMENT 'Yes/No - No=0, Yes=5'
) ENGINE = INNODB
COMMENT = 'Used to store individual reviews, all attributes are on a 1-5 integer scale.';
CREATE TABLE `theater_comments` (
`commentID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`theaterID` INT( 11 ) NOT NULL ,
`userID` INT( 11 ) NOT NULL COMMENT 'Who posted this comment?',
`timePosted` INT( 11 ) NOT NULL COMMENT 'PHP Generated timestamp.',
`title` VARCHAR( 100 ) NOT NULL ,
`comment` TEXT NOT NULL
) ENGINE = INNODB
COMMENT = 'Used to store comments specifically about a theater.';
CREATE TABLE `theater_likes` (
`theaterID` INT( 11 ) NOT NULL ,
`userID` INT( 11 ) NOT NULL ,
`likes` TINYINT( 1 ) NOT NULL COMMENT '0 for dislike, 1 for like.'
) ENGINE = INNODB
COMMENT = 'Stores all users votes whether it be like or dislike.';
CREATE TABLE `theater_images` (
`theaterID` INT( 11 ) NOT NULL ,
`userID` INT( 11 ) NOT NULL COMMENT 'User that uploaded the image.',
`imageLocation` VARCHAR( 150 ) NOT NULL COMMENT 'URL to the specific image.'
) ENGINE = INNODB
COMMENT = 'Used to store the locations of various images of the specific theater ID.';
CREATE TABLE `theater_visits` (
`theaterID` INT( 11 ) NOT NULL ,
`userID` INT( 11 ) NOT NULL COMMENT 'What user visited theaterID'
) ENGINE = INNODB
COMMENT = 'Stores what user has visited what theater.';