· 9 years ago · Oct 26, 2016, 02:26 PM
1CREATE TABLE IF NOT EXISTS `customers` (
2 `customerid` int(11) NOT NULL,
3 `name` char(50) NOT NULL,
4 `address` char(100) NOT NULL,
5 `city` char(30) NOT NULL
6)
7
8
9INSERT INTO `customers` (`customerid`, `name`, `address`, `city`) VALUES
10(1, 'John Smith', '454 Peacock St', 'Charleston WV'),
11(2, 'Billy Bob', '444 Kansas Parkway', 'Orlando Fl');
12
13
14CREATE TABLE IF NOT EXISTS `movies` (
15 `movie_id` int(11) NOT NULL,
16 `director` char(50) DEFAULT NULL,
17 `price` float(4,2) DEFAULT NULL,
18 `title` char(100) DEFAULT NULL
19)
20
21
22INSERT INTO `movies` (`movie_id`, `director`, `price`, `title`) VALUES
23(1, 'Jerry Bruckheimer', 25.00, 'Saving Private Ryan'),
24(2, 'Quentin Tarantino', 30.00, 'Fromm Dusk Till Dawn');
25
26
27
28CREATE TABLE IF NOT EXISTS `movie_reviews` (
29 `movie_id` int(11) NOT NULL,
30 `review` text NOT NULL
31)
32
33
34INSERT INTO `movie_reviews` (`movie_id`, `review`) VALUES
35(1, 'This movie was Awesome, loved the action, except for the ending.'),
36(2, 'Sorry, but this really sucks! ');
37
38
39
40CREATE TABLE IF NOT EXISTS `orders` (
41 `amount` float(6,2) NOT NULL,
42 `customerid` int(10) NOT NULL,
43 `date` date NOT NULL,
44 `orderid` int(11) NOT NULL
45)
46
47INSERT INTO `orders` (`amount`, `customerid`, `date`, `orderid`) VALUES
48(30.00, 1, '2016-10-04', 1),
49(25.00, 2, '2016-06-15', 2);
50
51
52
53CREATE TABLE IF NOT EXISTS `order_items` (
54 `orderid` int(10) unsigned NOT NULL,
55 `movieid` char(13) NOT NULL,
56 `quantity` tinyint(3) unsigned NOT NULL
57)
58
59INSERT INTO `order_items` (`orderid`, `movieid`, `quantity`) VALUES
60(1, '1', 3),
61(2, '2', 2);