-
Notifications
You must be signed in to change notification settings - Fork 0
/
installdatabase.php
81 lines (64 loc) · 1.61 KB
/
installdatabase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
#connect
include('sqlconnect.php');
#create database
$result = mysql_query("CREATE DATABASE bubbles");
if(!$result)
echo "Database not created " . mysql_error();
else
echo "Database created";
#select Database
mysql_query("USE bubbles");
#create tables
mysql_query("
CREATE TABLE IF NOT EXISTS Customer(
FirstName varchar(50),
LastName varchar(50),
CustomerID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (CustomerID))");
echo mysql_error();
mysql_query("
CREATE TABLE IF NOT EXISTS PhoneNumbers(
PhoneNumber varchar(11),
Type varchar(10),
CustomerID int NOT NULL,
PhoneNumberID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(PhoneNumberID),
FOREIGN KEY(CustomerID) REFERENCES Customer(CustomerID))");
echo mysql_error();
mysql_query("
CREATE TABLE IF NOT EXISTS Dog(
Price decimal(5,2),
Name varchar(50),
Breed varchar(50),
Instructions text,
Saturday bool,
DogID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (DogID))");
echo mysql_error();
mysql_query("
CREATE TABLE IF NOT EXISTS Owns(
CustomerID int NOT NULL,
DogID int Not NULL,
OwnID int NOT NULL AUTO_INCREMENT,
FOREIGN KEY(CustomerID) REFERENCES Customer(CustomerID),
FOREIGN KEY(DogID) REFERENCES Dog(DogID),
PRIMARY KEY(OwnID))");
echo mysql_error();
mysql_query("
CREATE TABLE IF NOT EXISTS Scheduled(
ScheduleID int NOT NULL AUTO_INCREMENT,
DateOfDay date NOT NULL,
TimeOfDay time,
SpecialComments text,
PM bool,
DogID int NOT NULL,
FOREIGN KEY(DogID) REFERENCES Dog(DogID),
PRIMARY KEY(ScheduleID))");
echo mysql_error();
?>
<html><body>
<form action="menu.php">
<input type = "submit" value = "Back to menu"/>
</form>
</body></html>