-- http://www.phpmyadmin.net
--




--
-- Database: `utopia`
--

-- --------------------------------------------------------

--
-- Table structure for table `book`
--

CREATE TABLE `book` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `author` varchar(100) NOT NULL,
  `course` varchar(50) NOT NULL,
  `price` int(11) NOT NULL DEFAULT '0',
  `health` varchar(200) NOT NULL,
  `owner_id` varchar(50) NOT NULL,
  `imageuploaded` tinyint(1) DEFAULT '0',
  `dispmyname` tinyint(1) DEFAULT '1',
  `dispmyemail` tinyint(1) DEFAULT '1',
  `dispmyphone` tinyint(1) DEFAULT '1',
  `dispmyhostel` tinyint(1) DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `book`
--

INSERT INTO `book` (`id`, `name`, `author`, `course`, `price`, `health`, `owner_id`, `imageuploaded`, `dispmyname`, `dispmyemail`, `dispmyphone`, `dispmyhostel`) VALUES
(2, 'Mathematics for Engineers', 'Rakesh Dube', 'Maths', 230, 'This is a very useful book for engineering freshers. The book is in good condition. Price is negotiable.', 'harshitkedia32@gmail.com', 1, 1, 1, 1, 1),
(3, 'Chemistry basics', 'ZumDahl', 'Chemistry', 310, 'This book is a must have for school science students. All important concepts are described clearly in this book. Important problems are also given.', 'akashsingh1@gmail.com', 1, 1, 1, 1, 1);

-- --------------------------------------------------------

--
-- Table structure for table `grievance`
--

CREATE TABLE `grievance` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `authority` varchar(100) NOT NULL,
  `health` varchar(200) NOT NULL,
  `location` varchar(200) NOT NULL,
  `owner_id` varchar(50) NOT NULL,
  `imageuploaded` tinyint(1) DEFAULT '0',
  `dispmyname` tinyint(1) DEFAULT '1',
  `dispmyemail` tinyint(1) DEFAULT '1',
  `dispmyphone` tinyint(1) DEFAULT '1',
  `dispmyhostel` tinyint(1) DEFAULT '1',
  `upvotes` int(11) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `grievance`
--

INSERT INTO `grievance` (`id`, `name`, `authority`, `health`, `location`, `owner_id`, `imageuploaded`, `dispmyname`, `dispmyemail`, `dispmyphone`, `dispmyhostel`, `upvotes`) VALUES
(1, 'Water shortage for 2 weeks', 'Municipal Corporation', 'The water is not coming for 18 hours. It is very difficult to manage. The authorities should take prompt action.', 'Katpadi', 'harshitkedia32@gmail.com', 1, 1, 1, 1, 1, 0),
(2, 'No Electricity in CMC', 'Municipal Corporation', 'There is no electricity in CMC for 8hrs per day. This is happening for last 10 days. Please take appropriate action.', 'CMC', 'harshit.kedia2015@vit.ac.in', 1, 1, 1, 1, 1, 2),
(3, 'Corruption of govt. officers', 'Chief Minister', 'The officers at the Passport office are asking bribe for making our passports. Please take appropriate actions', 'Katpadi', 'harshitkedia32@gmail.com', 1, 1, 1, 1, 1, 8);

-- --------------------------------------------------------

--
-- Table structure for table `news`
--

CREATE TABLE `news` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `health` varchar(200) NOT NULL,
  `location` varchar(200) NOT NULL,
  `owner_id` varchar(50) NOT NULL,
  `imageuploaded` tinyint(1) DEFAULT '0',
  `dispmyname` tinyint(1) DEFAULT '1',
  `dispmyemail` tinyint(1) DEFAULT '1',
  `dispmyphone` tinyint(1) DEFAULT '1',
  `dispmyhostel` tinyint(1) DEFAULT '1',
  `upvotes` int(11) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `news`
--

INSERT INTO `news` (`id`, `name`, `health`, `location`, `owner_id`, `imageuploaded`, `dispmyname`, `dispmyemail`, `dispmyphone`, `dispmyhostel`, `upvotes`) VALUES
(1, 'Fire in Awastha Apartment', 'A Fire broke out at Awastha Apartment, Karreli, Vellore. No death till now. Hundreds of residents injured. Resue operation needed immediately.', 'Karreli', 'harshitkedia32@gmail.com', 1, 0, 0, 1, 1, 4),
(2, 'Earthquake at Vellore', 'A severe Earthquake occurred in Vellore today. Hundreds of people died and were injured. More details coming soon.', 'Vellore', 'harshit.kedia2015@vit.ac.in', 1, 1, 1, 1, 1, 2);

-- --------------------------------------------------------

--
-- Table structure for table `recommendation`
--

CREATE TABLE `recommendation` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `authority` varchar(100) NOT NULL,
  `health` varchar(200) NOT NULL,
  `stars` int(11) DEFAULT NULL,
  `location` varchar(200) NOT NULL,
  `owner_id` varchar(50) NOT NULL,
  `imageuploaded` tinyint(1) DEFAULT '0',
  `dispmyname` tinyint(1) DEFAULT '1',
  `dispmyemail` tinyint(1) DEFAULT '1',
  `dispmyphone` tinyint(1) DEFAULT '1',
  `dispmyhostel` tinyint(1) DEFAULT '1',
  `upvotes` int(11) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `recommendation`
--

INSERT INTO `recommendation` (`id`, `name`, `authority`, `health`, `stars`, `location`, `owner_id`, `imageuploaded`, `dispmyname`, `dispmyemail`, `dispmyphone`, `dispmyhostel`, `upvotes`) VALUES
(1, 'Golmaal 3 is a great movie!', 'Movies', 'A very comedy movie. Great acting by Ajay Devgan. A must watch. A family entertainment.', 5, 'Park Street', 'harshitkedia32@gmail.com', 1, 1, 1, 1, 1, 3),
(2, 'Great food at Hundred Heritage', 'Restaurants', 'Hundred Heritage is a great place to have awesome food and great atmosphere. A must visit!', 4, 'katpadi', 'harshitkedia32@gmail.com', 1, 1, 1, 1, 1, 2);

-- --------------------------------------------------------

--
-- Table structure for table `requests`
--

CREATE TABLE `requests` (
  `id` int(11) NOT NULL,
  `from_id` varchar(50) NOT NULL,
  `to_id` varchar(50) NOT NULL,
  `book_id` int(11) NOT NULL,
  `readed` tinyint(1) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `requests`
--

INSERT INTO `requests` (`id`, `from_id`, `to_id`, `book_id`, `readed`) VALUES
(1, 'harshit.kedia2015@vit.ac.in', 'harshitkedia32@gmail.com', 2, 0),
(2, 'harshitkedia32@gmail.com', 'akashsingh1@gmail.com', 3, 0),
(3, 'akashsingh1@gmail.com', 'harshitkedia32@gmail.com', 2, 0);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `book`
--
ALTER TABLE `book`
  ADD PRIMARY KEY (`id`),
  ADD KEY `owner_id` (`owner_id`);

--
-- Indexes for table `grievance`
--
ALTER TABLE `grievance`
  ADD PRIMARY KEY (`id`),
  ADD KEY `owner_id` (`owner_id`);

--
-- Indexes for table `news`
--
ALTER TABLE `news`
  ADD PRIMARY KEY (`id`),
  ADD KEY `owner_id` (`owner_id`);

--
-- Indexes for table `recommendation`
--
ALTER TABLE `recommendation`
  ADD PRIMARY KEY (`id`),
  ADD KEY `owner_id` (`owner_id`);

--
-- Indexes for table `requests`
--
ALTER TABLE `requests`
  ADD PRIMARY KEY (`id`),
  ADD KEY `to_id` (`to_id`),
  ADD KEY `from_id` (`from_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `book`
--
ALTER TABLE `book`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `grievance`
--
ALTER TABLE `grievance`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `news`
--
ALTER TABLE `news`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `recommendation`
--
ALTER TABLE `recommendation`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `requests`
--
ALTER TABLE `requests`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `book`
--
ALTER TABLE `book`
  ADD CONSTRAINT `book_ibfk_1` FOREIGN KEY (`owner_id`) REFERENCES `user` (`regno`);

--
-- Constraints for table `grievance`
--
ALTER TABLE `grievance`
  ADD CONSTRAINT `grievance_ibfk_1` FOREIGN KEY (`owner_id`) REFERENCES `user` (`regno`);

--
-- Constraints for table `news`
--
ALTER TABLE `news`
  ADD CONSTRAINT `news_ibfk_1` FOREIGN KEY (`owner_id`) REFERENCES `user` (`regno`);

--
-- Constraints for table `recommendation`
--
ALTER TABLE `recommendation`
  ADD CONSTRAINT `recommendation_ibfk_1` FOREIGN KEY (`owner_id`) REFERENCES `user` (`regno`);

--
-- Constraints for table `requests`
--
ALTER TABLE `requests`
  ADD CONSTRAINT `requests_ibfk_1` FOREIGN KEY (`to_id`) REFERENCES `user` (`regno`),
  ADD CONSTRAINT `requests_ibfk_2` FOREIGN KEY (`from_id`) REFERENCES `user` (`regno`);

