Question

Consider the following relational database:               STUDENT     (STDNO, SNAME, DEPTNO#)             &n

Consider the following relational database:

              STUDENT     (STDNO, SNAME, DEPTNO#)

              DEP                 (DEPTNO, DNAME)

              COURSE        (CORSNO, CNAME, DEPTNO#, CMAX)

              ENROLMENT       (STDNO#, CORSNO#, GRADE, EDATE)

STUDENT.DEPTNO is the department number of the student.

COURSE.DEPTNO is the department number that offers the course.

ENROLMENT models the registrations of students in courses (M:M relationship) where the GRADE is the grade obtained by the student in the course.

PART I : DATA DESCRIPTION LANGUAGE (DDL)

  1. Write DDL commands to create the four tables without any constraint.

Nom de colonne

Signification

Type

Size

STDNO

Student Number

Number

8

SNAME

Student name

Varchar2

30

DEPTNO

Department Number

Varchar2

2

DNAME

Department name

Varchar2

20

CORSNO

Course Number

Number

3

CNAME

Course Name

Varchar2

30

CMAX

Max. students allowed

Number

2

GRADE

Obtained Grade

Number

2

EDATE

Enrolment date

Date

-

  1. Add all the following constraints:
  • Primary Key
  • Foreign Key
  • Constraints on the STUDENT table:
    • Sname: Mandatory
    • Each student must belong to a department
  • Constraint on the DEP table
    • Sname : Uppercase
  • Constraint on the COURSE table
    • Cmax: in the range 5 to 50 students
  • Constraint on the ENROLMENT table
  1. Edate: have a default value equal to the system date, Mandatory.

Homework Answers

Answer #1

DDL Commands to create without constraints:

  • create table STUDENT (STDNO integer(8),SNAME varchar(30),DEPTNO varchar(2));
  • create table DEP(DEPTNO varchar(2),dname varchar(20));
  • create table COURSE(CORSNO integer(3),CNAME varchar(30),DEPTNO varchar(2),CMAX integer(2));
  • create table ENROLMENT(STDNO integer(2),CORSNO integer(3),GRADE integer(2),EDATE DATETIME);

Adding Constraints:

  • alter table STUDENT add primary key(SNAME);
  • alter table DEP add primary key(DEPTNO);
  • alter table STUDENT add foreign key(DEPTNO) references DEP(DEPTNO);
  • alter table DEP change dname DNAME varchar(20);
  • alter table COURSE change CMAX CMAX integer(50);
  • ALTER TABLE ENROLMENT MODIFY COLUMN EDATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP;

Output Screenshots:

Thank you have a great day...Please do like....

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1) Add to a relational table DEPARTMENT information about the total number of employees in each...
1) Add to a relational table DEPARTMENT information about the total number of employees in each department. Note, that if a department has not employee then for such a department the total number of employees must be set to zero (0). The total number of employees must be a positive number no more than 999. Use SELECT statement to list the contents of an extended relational table DEPARTMENT in the descending order of the total number of employees. Finally, remove...
1.Consider the following (normalized) relational model (primary keys are underlined, foreign keys are in italics). EMPLOYEE(SSN,...
1.Consider the following (normalized) relational model (primary keys are underlined, foreign keys are in italics). EMPLOYEE(SSN, ENAME, EADDRESS, SEX, DATE_OF_BIRTH, SUPERVISOR, DNR) S U P E R V I S O R : foreign key refers to SSN in EMPLOYEE, NULL value allowed D N R : foreign key refers to DNR in DEPARTMENT, NULL value not allowed DEPARTMENT(DNR, DNAME, DLOCATION, MGNR) MGNR: foreign key refers to SSN in EMPLOYEE, NULL value not allowed PROJECT(PNR, PNAME, PDURATION, DNR) DNR: foreign...
Given the following relational database schema: Student = (SSN, Name, Major) Course = ( CourseNumber, PrerequisiteCourseNumber,...
Given the following relational database schema: Student = (SSN, Name, Major) Course = ( CourseNumber, PrerequisiteCourseNumber, Course Title, NumberUnits) Section = ( CourseNumber, Quarter, RoomNumber, DayTime), where DayTime is of the form MW 1:0-2:00PM. Enrollment = (SSN,CourseNumber, Quarter, Grade)// Grade is either Null or a letter grade. I'm looking for the DLL statements to make the tables above in SQL
SQL Data: you can just copy paste it into mysql to. CREATE DATABASE University;USE University; CREATE...
SQL Data: you can just copy paste it into mysql to. CREATE DATABASE University;USE University; CREATE TABLE Student (  sid INT PRIMARY KEY,  name VARCHAR(20) NOT NULL,  address VARCHAR(20) NOT NULL,  major CHAR(2)); CREATE TABLE Professor (  pid INT PRIMARY KEY,  name VARCHAR(20) NOT NULL,  department VARCHAR(10) NOT NULL); CREATE TABLE Course (  cid INT PRIMARY KEY,  title VARCHAR(20) NOT NULL UNIQUE,  credits INT NOT NULL,  area VARCHAR(5) NOT NULL); CREATE TABLE Transcript (  sid INT,  cid INT,  pid INT,  semester VARCHAR(9),  year YEAR,  grade CHAR(1) NOT NULL,  PRIMARY KEY (sid, cid, semester, year),  FOREIGN KEY (sid) REFERENCES Student...
Consider a relational DBMS that has two relations: Emp (employees) and Dept (departments).    Emp(id, name,...
Consider a relational DBMS that has two relations: Emp (employees) and Dept (departments).    Emp(id, name, age, salary, dname)    Dept(dname, location) - The Emp table has 500 tuples, and each tuple has a fixed length of 500 bytes. The primary key attribute "id" has a length of 40 bytes. - The Dept table has 100 tuples, and each tuple has 200 bytes. The primary key attribute "dname" has a length of 20 bytes. For simplicity, we assume each employee...
Develop an application to support course administration. Read the following detailed description of this application, and...
Develop an application to support course administration. Read the following detailed description of this application, and complete the tasks listed below. *. A course has a unique course number and title, and is assigned to one or more areas of the Computer Science program. Each course has an instructor, at least one teaching or research assistant, an online conference whiteboard, a time (interval), and a capacity (maximum number of participants). A course need not be offered each term, but the...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a small number of records. However, the data contained within it is expected to grow significantly in the future. Creating indexes on commonly searched columns is a way performance issues can be minimized. Write a command to create an index on student_name column of the student table. Create view – 1 mark Write a command to create a view to list the student ID and...
/* myCompany.SQL Introduction to SQL Script file for ORACLE DBMS This script file creates the following...
/* myCompany.SQL Introduction to SQL Script file for ORACLE DBMS This script file creates the following tables: VENDOR, PRODUCT, CUSTOMER, INVOICE, LINE EMPLOYEE and loads the default data rows */ set echo on; set serveroutput on; select systimestamp from dual; show user; ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY'; DROP TABLE LINE CASCADE CONSTRAINTS; DROP TABLE INVOICE CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE VENDOR CASCADE CONSTRAINTS; DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE...