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);
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,
52
//Create Resturasts tabel
54
CREATE TABLE IF NOT EXISTS Resturants(
55
id integer PRIMARY KEY,
56
name varchar(64) NOT NULL,
57
city varchar(64) NOT NULL,
58
phoneNumber varchar(64) NOT NULL,
63
//Create Interests Table - This table stores the intrests a user may have.
65
CREATE TABLE IF NOT EXISTS Interests(
66
interest varchar(64) PRIMARY KEY
70
//Create FoodTypes table - this table stores the different types of food thet
73
CREATE TABLE IF NOT EXISTS FoodTypes(
74
foodType varchar(64) PRIMARY KEY
79
$db->beginTransaction();
82
CREATE TABLE IF NOT EXISTS UserIntrests(
83
loginName varchar(64),
85
FOREIGN KEY(loginName) REFERENCES Users(loginName),
86
FOREIGN KEY(interest) REFERENCES Interests(interest),
87
PRIMARY KEY(loginName, interest)
93
CREATE TABLE IF NOT EXISTS UserFoodTypes(
94
loginName varchar(64),
96
FOREIGN KEY(loginName) REFERENCES Users(loginName),
97
FOREIGN KEY(foodType) REFERENCES FoodTypes(foodType),
98
PRIMARY KEY(loginName, foodType)
101
} catch (PDOException $err) {