Create a new database called "School" this database should have two
tables: teachers and students.
The students table should have columns for student_id, first_name,
last_name, homeroom_number, phone,email, and graduation year.
The teachers table should have columns for teacher_id, first_name, last
_name, homeroom_number, department, email, and phone.
The constraints are mostly up to you, but your table constraints do have
to consider the following:
1. We must have a phone number to contact students in case of an
emergency.
2. We must have ids as the primary key of the tables
3. Phone numbers and emails must be unique to the individual.
Once you've made the tables, insert a student named Mark
Watney (student_id=1) who has a phone number of 777-555-1234 and
doesn't have an email. He graduates in 2035 and has 5 as a homeroom
number.
Then insert a teacher names Jonas Salk (teacher_id = 1) who as a
homeroom number of 5 and is from the Biology department. His contact
info is:
[email protected] and a phone number of 777-555-4321.
Keep in mind that these insert tasks may effect your constraints!
To create the students table:
1. CREATE TABLE students(
2. student_id serial PRIMARY KEY,
3. first_name VARCHAR(45) NOT NULL,
4. last_name VARCHAR(45) NOT NULL,
5. homeroom_number integer,
6. phone VARCHAR(20) UNIQUE NOT NULL,
7. email VARCHAR(115) UNIQUE,
8. grad_year integer);
To create the teachers table:
1. CREATE TABLE teachers(
2. teacher_id serial PRIMARY KEY,
3. first_name VARCHAR(45) NOT NULL,
4. last_name VARCHAR(45) NOT NULL,
5. homeroom_number integer,
6. department VARCHAR(45),
7. email VARCHAR(20) UNIQUE,
8. phone VARCHAR(20) UNIQUE);
Then for inserting the student information:
1. INSERT INTO students(first_name,last_name,
homeroom_number,phone,grad_year)
VALUES ('Mark','Watney',5,'7755551234',2035);
Then for inserting the teacher information:
1. INSERT INTO teachers(first_name,last_name,
homeroom_number,department,email,phone)
VALUES ('Jonas','Salk',5,'Biology','
[email protected]','7755554321');