Question: SQL Help a) Using the code in Advising.sql below, identify the tables and relationships in the database. (Here is the Advising.sql) CREATE DATABASE studentMajors GO

SQL Help

a) Using the code in Advising.sql below, identify the tables and relationships in the database.

(Here is the Advising.sql)

CREATE DATABASE studentMajors

GO

USE studentMajors

GO

CREATE TABLE Advisors

(advisorid int identity primary key,

advisorFirstName varchar(25) not null,

advisorLastName varchar(35) not null,

building char(2) not null CHECK (building LIKE '[0-9][0-9]'),

room char(3) not null CHECK (room LIKE '[0-9][0-9][0-9]'),

extension char(4) not null check (extension LIKE '[0-9][0-9][0-9][0-9]'))

GO

CREATE TABLE Majors

(majorid int identity primary key,

major varchar(50) not null,

department varchar(5) not null check (department LIKE '[A-Z][A-Z]' OR

department LIKE '[A-Z][A-Z][A-Z]' OR department LIKE '[A-Z][A-Z][A-Z][A-Z]' OR

department LIKE '[A-Z][A-Z][A-Z][A-Z][A-Z]'))

GO

CREATE TABLE MajorAdvisors

(majorid int NOT NULL references majors,

advisorid int NOT NULL references advisors)

CREATE TABLE Students

(studentFirst varchar(25) NOT NULL,

studentLast varchar(35) NOT NULL,

studentid char(9) NOT NULL PRIMARY KEY

CHECK (studentID like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'))

GO

CREATE TABLE StudentMajors

(studentid char(9) NOT NULL references students,

majorid int NOT NULL references majors,

chooseDate date check (chooseDate <= getdate()),

advisorid int NOT NULL references advisors)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!