Photo Video Gallery–Database Design

MySQL DBMS

Database design for photo video gallery website / app. Enjoy.

Schema Diagram:

pvgallery
MySQL Create script:
— phpMyAdmin SQL Dump
— version 3.2.0.1
http://www.phpmyadmin.net

— Host: localhost
— Generation Time: Apr 03, 2013 at 10:25 PM
— Server version: 5.1.37
— PHP Version: 5.3.0

SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;


— Database: `pvgallery`

— ——————————————————–


— Table structure for table `category`

CREATE TABLE IF NOT EXISTS `category` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`details` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


— Dumping data for table `category`

— ——————————————————–


— Table structure for table `comments`

CREATE TABLE IF NOT EXISTS `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`media_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`comment_text` text CHARACTER SET utf8 NOT NULL,
`created_at` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


— Dumping data for table `comments`

— ——————————————————–


— Table structure for table `media`

CREATE TABLE IF NOT EXISTS `media` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 NOT NULL,
`description` text CHARACTER SET utf8 NOT NULL,
`file` varchar(255) NOT NULL,
`size` int(11) NOT NULL,
`likes` int(11) DEFAULT NULL,
`views` int(11) DEFAULT NULL,
`downloads` int(11) DEFAULT NULL,
`category_id` int(11) DEFAULT NULL,
`user_id` int(11) NOT NULL,
`media_type_id` int(11) NOT NULL,
`created_at` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


— Dumping data for table `media`

— ——————————————————–


— Table structure for table `media_type`

CREATE TABLE IF NOT EXISTS `media_type` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`slug` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;


— Dumping data for table `media_type`

INSERT INTO `media_type` (`id`, `name`, `slug`) VALUES
(1, ‘Videos’, ‘videos’),
(2, ‘Photos’, ‘photo’),
(3, ‘Music’, ‘music’);

— ——————————————————–


— Table structure for table `users`

CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`type` int(11) NOT NULL,
`created_at` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


— Dumping data for table `users`

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

Leave a Reply

Your email address will not be published. Required fields are marked *