-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_Tables.php
69 lines (56 loc) · 1.8 KB
/
create_Tables.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
require('db_conn.php');
// sql to create table
$Users = 'CREATE TABLE `users` (
`id` int(11) NOT NULL,
`user_name` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL
)';
if ($conn->query($Users ) === TRUE) {
echo "Table Users created successfully";
} else {
echo "Error creating table Users: " . $conn->error;
}
$Candidate = "CREATE TABLE Candidate (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
age INT(2),
qualification ENUM('Certificate','Diploma','Degree','Masters'),
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
if ($conn->query($Candidate ) === TRUE) {
echo "Table Candidate created successfully";
} else {
echo "Error creating table Candidate: " . $conn->error;
}
$Question = "CREATE TABLE Question (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
question VARCHAR(300) NOT NULL,
points Int(2) NOT NULL,
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
if ($conn->query($Question ) === TRUE) {
echo "Table Question created successfully";
} else {
echo "Error creating Question table: " . $conn->error;
}
$Interview = "CREATE TABLE Interview (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
question INT UNSIGNED NOT NULL,
candidate INT UNSIGNED NOT NULL,
report VARCHAR(500),
marks INT(100),
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (question) REFERENCES Question(id),
FOREIGN KEY (candidate) REFERENCES Candidate(id)
)";
if ($conn->query($Interview ) === TRUE) {
echo "Table Interview created successfully";
} else {
echo "Error creating Interview table: " . $conn->error;
}
$conn->close();
?>