3
ExtremeDating - a Hackathon 2013 project.
4
Copyright (C) 2013 Gustav Hartvigsson <gustav.hartvigsson@gmail.com>
5
Copyright (C) 2013 Daniel Johansson <maila@danieljohansson.nu>
8
This program is free software: you can redistribute it and/or modify
9
it under the terms of the GNU Affero General Public License as
10
published by the Free Software Foundation, either version 3 of the
11
License, or (at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU Affero General Public License for more details.
18
You should have received a copy of the GNU Affero General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
$db = new PDO("sqlite:./database.db");
24
$db->setAttribute(PDO::ATTR_ERRMODE,
25
PDO::ERRMODE_EXCEPTION);
29
Users(_loginName_, shadow, firstName, surName, city, eMail, profileImage, userType);
30
Resturants(_id_, name, city, phoneNumber, theme);
31
# Theme is if it is, say, a pizzeria or a french resturant or something.
32
Interests(_interest_);
34
UserInterests(-loginName-, -interest-);
35
UserFoodTypes(-loginName-, -foodType-);
40
CREATE TABLE IF NOT EXISTS Users(
41
loginName varchar(64) PRIMARY KEY,
42
shadow varchar(64) NOT NULL,
43
firstName varchar(64) NOT NULL,
44
surName varchar(64) NOT NULL,
45
city varchar(64) NOT NULL,
46
eMail varchar(64) NOT NULL,
53
//Create Resturants tabel
55
CREATE TABLE IF NOT EXISTS Resturants(
56
id integer PRIMARY KEY,
57
name varchar(64) NOT NULL,
58
city varchar(64) NOT NULL,
59
phoneNumber varchar(64) NOT NULL,
64
//Create Interests Table - This table stores the intrests a user may have.
66
CREATE TABLE IF NOT EXISTS Interests(
67
interest varchar(64) PRIMARY KEY
71
//Create FoodTypes table - this table stores the different types of food thet
74
CREATE TABLE IF NOT EXISTS FoodTypes(
75
foodType varchar(64) PRIMARY KEY
80
$db->beginTransaction();
82
$arr = array('husman','kina','thai','mex','italienskt','franskt','grekisk',
83
'fika','efterrätter');
84
foreach ($arr as $i) {
87
INSERT OR IGNORE INTO FoodTypes VALUES('{$i}');
93
} catch (PDOException $err) {
99
$db->beginTransaction();
100
$arr = array('php','sql','GNU/Linux','Nix','HP','mat','3d','hen-gris');
101
foreach ($arr as $i) {
104
INSERT OR IGNORE INTO Interests VALUES('{$i}');
110
} catch (PDOException $err) {
116
$db->beginTransaction();
119
CREATE TABLE IF NOT EXISTS UserIntrests(
120
loginName varchar(64),
121
interest varchar(64),
122
FOREIGN KEY(loginName) REFERENCES Users(loginName),
123
FOREIGN KEY(interest) REFERENCES Interests(interest),
124
PRIMARY KEY(loginName, interest)
130
CREATE TABLE IF NOT EXISTS UserFoodTypes(
131
loginName varchar(64),
132
foodType varchar(64),
133
FOREIGN KEY(loginName) REFERENCES Users(loginName),
134
FOREIGN KEY(foodType) REFERENCES FoodTypes(foodType),
135
PRIMARY KEY(loginName, foodType)
140
CREATE TABLE IF NOT EXISTS dateInterests(
143
FOREIGN KEY(user1) REFERENCES Users(loginName),
144
FOREIGN KEY(user2) REFERENCES Users(loginName),
145
PRIMARY KEY(user1, user2)
150
CREATE TABLE IF NOT EXISTS planLunch(
153
message varchar(1024),
156
FOREIGN KEY(user1) REFERENCES Users(loginName),
157
FOREIGN KEY(user2) REFERENCES Users(loginName),
158
PRIMARY KEY(user1, user2)
162
} catch (PDOException $err) {