Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

CS526_18263_Hw5_Harikrishna Bandla

DBFiles
restaurant_db.sql
/*
Student Info: Name=Harikrishna Bandla, ID=18263
Subject: CS526B_HW5_Spring_2016
Author: Harie
Filename: restaurant_db.sql
Date and Time: Mar 20, 2016 5:31:45 PM
Project Name: Restaurant_Application_18263
*/
DROP DATABASE IF EXISTS restaurant_db;

CREATE DATABASE restaurant_db;

USE restaurant_db;
CREATE TABLE categories (
categoryID

INT(11)

categoryName

NOT NULL AUTO_INCREMENT,

VARCHAR(255) NOT NULL,

PRIMARY KEY (categoryID)


);
CREATE TABLE fooditems (
foodItemID
categoryID

INT(11)
INT(11)

foodItemName
foodItemPrice

NOT NULL AUTO_INCREMENT,


NOT NULL,

VARCHAR(255) NOT NULL,


DECIMAL(10,2) NOT NULL,

PRIMARY KEY (foodItemID)


);

INSERT INTO categories VALUES


(1, 'Breakfast'),
(2, 'Lunch'),
(3, 'Dinner'),
(4, 'Drinks');

INSERT INTO fooditems VALUES


(1, 1, 'Samber Idly', '2.00'),
(2, 2, 'chicken kababs', '9.99'),
(3, 3, 'Curd rice','12.17'),
(4, 4, 'donuts','1.99'),

(5, 1, 'chicken manchuria', '3.99'),


(6, 2, 'masala papad', '2.00'),
(7, 3, 'Prawns Biryani', '9.99'),
(8, 4, 'Coke','12.17');
select * from categories;
select * from fooditems;
SELECT * FROM fooditems INNER JOIN categories ON fooditems.categoryID = categories.categoryID
ORDER BY foodItemID;

GRANT SELECT, INSERT, DELETE, UPDATE


ON restaurant_db.*
TO root@localhost
IDENTIFIED BY '';
GRANT SELECT
ON fooditems
TO root@localhost
IDENTIFIED BY '';

db_connect.php
<!-Student Info: Name=Harikrishna Bandla, ID=18263

Subject: CS526B_HW5_Spring_2016
Author: Harie
Filename: db_connect.php
Date and Time: Mar 20, 2016 5:45:45 PM
Project Name: Restaurant_Application_18263
-->
<?php

$dsn = 'mysql:host=localhost;dbname=restaurant_db';
$username = 'root';
$password = '';
try {
$db = new PDO($dsn, $username, $password);
echo 'Connected.';
} catch (PDOException $ex) {
$error_msg = $ex->getMessage();
include('db_error.php');
exit();
}
?>

You might also like