-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreateTables.js
98 lines (71 loc) · 2.86 KB
/
createTables.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const mysql = require('mysql2/promise')
const insertValues = require('./insertValues.js')
const createTables = async () =>{
const connection = await mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'sunil', // Modify to mYSQL paswiord
database: 'dbmsproj' // Create a database called iris in ur mysql
})
// Creating the table
await connection.execute(`CREATE TABLE IF NOT EXISTS Student (
Reg_no int,
Password varchar(50),
Name varchar(50),
Email varchar(50),
CGPA decimal(3,1),
Credits_Obtained int,
Fee_Paid boolean,
Semester int,
Department_id int,
PRIMARY KEY (Reg_no)
)`);
await connection.execute(`CREATE TABLE IF NOT EXISTS Department(
Department_id int,
Department_name varchar(50),
PRIMARY KEY (Department_id)
)`);
await connection.execute(`CREATE TABLE IF NOT EXISTS Companies (
Company_id int,
Dept_id int,
Salary_offered float,
Company_name varchar(30),
PRIMARY KEY (Company_id)
)`);
await connection.execute(`CREATE TABLE IF NOT EXISTS Alumni_Message (
Reg_no int,
Message varchar(200)
)`);
await connection.execute(`CREATE TABLE IF NOT EXISTS Alumni (
Reg_no int,
Dept int,
Company_id int,
Name varchar(200),
PRIMARY KEY (Reg_no)
)`);
await connection.execute(`CREATE TABLE IF NOT EXISTS Professor (
Professor_id int,
Department_id int,
Name varchar(50),
Course_id int,
PRIMARY KEY (Professor_id)
)`);
await connection.execute(`CREATE TABLE IF NOT EXISTS Results (
Course_id int,
Student_Reg_no int,
Score_obtained decimal(3,1)
)`);
await connection.execute(`CREATE TABLE IF NOT EXISTS Course_info (
Course_id int,
Course_name varchar(50),
Credits int,
PRIMARY KEY (Course_id)
)`);
await connection.execute( `CREATE TABLE IF NOT EXISTS Fee_transaction (
Reg_no int,
Amount_paid int,
Semester int
)`);
await insertValues();
}
module.exports = createTables;