-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateDatabase.php
More file actions
61 lines (53 loc) · 1.3 KB
/
createDatabase.php
File metadata and controls
61 lines (53 loc) · 1.3 KB
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
<?php
include 'config.php';
// Create database
$sql = "CREATE DATABASE gsm";
if ($conn->query($sql) === TRUE) {
echo "Database created successfully";
} else {
echo "Error creating database: " . $conn->error;
}
mysqli_select_db($conn, 'gsm');
// sql to create table
$sql = "CREATE TABLE cell_tower (
mnc INT(6) NOT NULL,
mcc INT(6) NOT NULL,
lac INT(6) NOT NULL,
ci INT(6) NOT NULL,
PRIMARY KEY(lac, ci)
)";
if ($conn->query($sql) === TRUE) {
echo "Table cell_tower created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
$sql = "CREATE TABLE cell_phone (
tmsi VARCHAR(32),
last_seen DATETIME NOT NULL,
signal_strength INT(3) NOT NULL,
lac INT(6) NOT NULL,
ci INT(6) NOT NULL,
FOREIGN KEY(lac, ci) REFERENCES cell_tower(lac, ci),
PRIMARY KEY(tmsi, lac, ci)
)";
if ($conn->query($sql) === TRUE) {
echo "Table cell_tower created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
$sql = "CREATE TABLE cell_connection (
lac INT(6),
ci INT(6),
stamp DATETIME,
new INT(4) NOT NULL,
repeated INT(4) NOT NULL,
FOREIGN KEY(lac, ci) REFERENCES cell_tower(lac, ci),
PRIMARY KEY(lac, ci, stamp)
)";
if ($conn->query($sql) === TRUE) {
echo "Table cell_connection created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
$conn->close();
?>