· 5 years ago · Feb 10, 2020, 10:08 PM
1--Create DB--
2DROP DATABASE IF EXISTS My_Database;
3CREATE DATABASE My_Database;
4USE My_Database;
5
6
7--Student Table--
8create TABLE students (
9 studentID INT(11) NOT NULL AUTO_INCREMENT,
10 studentName VARCHAR(255) NOT NULL,
11 studentAge INT(11)
12
13 PRIMARY KEY(studentID)
14
15);
16
17--Faculty Table--
18create TABLE faculty (
19 facultyID INT(11) NOT NULL AUTO_INCREMENT,
20 facultyName VARCHAR(255) NOT NULL,
21 yearsTaught INT(11)
22
23 PRIMARY KEY(facyltyID)
24
25);
26
27
28--Class Table--
29create TABLE class (
30 classID INT(11) NOT NULL AUTO_INCREMENT,
31 className VARCHAR(255) NOT NULL
32
33 PRIMARY KEY(facyltyID)
34
35);
36
37
38
39INSERT INTO students VALUES
40(1, '404', 'Michael Mech', '18' ),
41(2, '500', 'Mitch Mores', '19');
42
43INSERT INTO faculty VALUES
44(1, '200', 'Tom Mores', '23'),
45(1, '200', 'Metha Peace', 21);
46
47INSERT INTO class VALUES
48(1, '150', 'INTRO TO COMPUTERS'),
49(2, '250', 'Comp 2');
50
51--Privileges--
52GRANT SELECT, INSERT, DELETE, UPDATE
53on My_Database.*
54TO mgs_user@localhost
55IDENTIFIED BY 'pa55word';
56
57GRANT SELECT
58ON students
59TO mgs_tester@localhost
60IDENTIFIED BY 'pa55word';