Question

In: Computer Science

Database Systems Lab Exercises Create a table Faculty based on the following chart: Column Data type...

Database Systems

Lab Exercises

  1. Create a table Faculty based on the following chart:

Column

Data type

Constraints

Faculty_Id

Number (6)

Primary Key => faculty_pk

Last_Name

Varchar2(15)

Not NULL

First_Name

Varchar2(15)

Not NULL

Dept

Char(3)

Save the SQL statement as ex1.sql. Confirm and validate the creation of the new table.

  1. Create a table Dept based on the following chart:

Column

Data type

Constraints

Dept_Code

Char (3)

Primary Key => dept_pk

Dept_Name

Varchar2(20)

Not NULL

Save the SQL statement as ex2.sql. Confirm and validate the creation of the new table.

  1. Add a new column Location to Dept table which has data type Char(7). Save the SQL statement as exsql. Confirm and validate the modification of the table.
  2. Add a new FOREIGN KEY constraint (named faculty_dept_fk) to column Dept on Faculty table that refers to column Dept_Code on Dept table. Add ON DELETE CASCADE option. Save the SQL statement as exsql. Confirm and validate the modification of the table.
  1. Increase Last_Name column to 25 characters long. Save the SQL statement as exsql. Confirm and validate the modification of the table

use this to draw https://www.diagrameditor.com/

Solutions

Expert Solution

Ex1.sql:

CREATE TABLE Faculty(
    Faculty_Id            Number (6) NOT NULL,
    Last_Name   Varchar2(15) NOT NULL,
    First_Name   Varchar2(15) NOT NULL,
    Dept   Char(3),
    CONSTRAINT Faculty_pk PRIMARY KEY(Faculty_Id)
    );

Ex2.sql;

CREATE TABLE Dept(
    Dept_Code            Char(3) NOT NULL,
    Dept_Name   Varchar2(20) NOT NULL,
    CONSTRAINT Dept_pk PRIMARY KEY(Dept_Code)
    );

Deccription of the created table:


    select *
  from user_tab_columns

Exsql.sql;

Add location:

 Alter table Dept
  ADD Location Char(7);

    select *
  from user_tab_columns

exsql.sql

Alter table Faculty
ADD Constraint Faculty_Dept_fk FOREIGN KEY(Dept) REFERENCES Dept(Dept_Code)on delete cascade;

exsql.sql

SQL Server / MS Access:

ALTER TABLE Faculty
ALTER COLUMN last_name Varchar2(25);

My SQL / Oracle (prior version 10G):

ALTER TABLE Faculty
MODIFY COLUMN last_name Varchar2(25);

Oracle 10G and later:

ALTER TABLE Faculty
MODIFY last_name Varchar2(25);

    select *
  from user_tab_columns

Since you have not mentioned the diagram that is needed, I have drawn a basic diagram .Hope that helps!


Related Solutions

Database Systems Lab Exercises Populate the Dept table with the following: Dept_Code Dept_Name ICS Information and...
Database Systems Lab Exercises Populate the Dept table with the following: Dept_Code Dept_Name ICS Information and Computer Science COE Computer Engineering SWE Software Engineering SE System Engineering Populate the Faculty table with the following: Faculty_Id Last_Name First_Name Dept 100234 Hashim Ahmad ICS 287234 Yoesuf Mohammed COE 767636 Amn Faisal ICS 557899 Hamzah Yusuf SE 345256 Lukman Mousa SWE 626277 Ali Isa COE 246266 Dawood Ageel SE Change the last name of Faculty Id = 767636 to "Ameen". Change the Dept...
Use the data in the following table to create a fraction nonconforming (p) chart. The column...
Use the data in the following table to create a fraction nonconforming (p) chart. The column of np represents the number of non-conforming units. Is the process in control? (5 points) Sample n np p 1 100 7 0.07 2 100 10 0.10 3 100 12 0.12 4 100 4 0.04 5 100 9 0.09 6 100 11 0.11 7 100 10 0.10 8 100 18 0.18 9 100 13 0.13 10 100 21 0.21 Question 2 A bank's manager...
Create a 15 row and 4 column table with each column of the data so that...
Create a 15 row and 4 column table with each column of the data so that it goes 1A 1B 1C 1D across using this code as a base void PrintSeatingChart(seat seats[15][4], int numRows, int numColumns) {    int i;    int j;    for (i = 0; i < numRows; i++) {        cout << i + 1 << " ";        for (j = 0; j < numColumns; j++) {            cout << seats[i][j].seatLetter...
Review the chart of accounts in Ch 2. In Excel, create a four column chart of...
Review the chart of accounts in Ch 2. In Excel, create a four column chart of accounts for a fictitious company in your pathway. The company should be a sole proprietor and a service business. In the upper left side of your worksheet list your name, your company name and your pathway. Write a short description of what your company does. Your Chart of Accounts must include the following: List at least 16 accounts. At least 6 account titles should...
Review the chart of accounts in Ch 2. In Excel, create a four column chart of...
Review the chart of accounts in Ch 2. In Excel, create a four column chart of accounts for a fictitious company in your pathway. The company should be a sole proprietor and a service business. In the upper left side of your worksheet list your name, your company name and your pathway. Write a short description of what your company does. Your Chart of Accounts must include the following: List at least 16 accounts. At least 6 account titles should...
Review the chart of accounts in Ch 2. In Excel, create a four column chart of...
Review the chart of accounts in Ch 2. In Excel, create a four column chart of accounts for a fictitious company in your pathway. The company should be a sole proprietor and a service business. In the upper left side of your worksheet list your name, your company name and your pathway. Write a short description of what your company does. Your Chart of Accounts must include the following: List at least 16 accounts. At least 6 account titles should...
Information on the following Database: create database Sales_Co use Sales_Co create table Vendor (v_code integer, v_name...
Information on the following Database: create database Sales_Co use Sales_Co create table Vendor (v_code integer, v_name varchar(35) not null, v_contact varchar(15) not null, v_areacode char(3) not null, v_phone char(8) not null, v_state char(2) not null, v_order char(1) not null, primary key (v_code)); create table product (p_code varchar(10) constraint product_p_code_pk primary key, p_descript varchar(35) not null, p_indate datetime not null, p_qoh integer not null, p_min integer not null, p_price numeric (8,2) not null, p_discount numeric (4,2) not null, v_code integer, constraint...
SQL query exercises: Consider the following database schema:                Product(maker, model, type)              &
SQL query exercises: Consider the following database schema:                Product(maker, model, type)                PC(model, speed, ram, hd, rd, price)                Laptop(model, speed, ram, hd, screen, price)                Printer(model, color, type, price) Consider the Drivers-Cars-Reserves DB for a small rental car company:                Drivers(id, name, rating, age)                Cars(vin, maker, model, year, color)                Reserves(did, vin, date) Give SQL statement each of the following operations: Find the colors of cars reserved by Smith. Find all id’s of drivers who have a...
Emergency Chart Create a chart of medical emergencies and the level of required care. Column one,...
Emergency Chart Create a chart of medical emergencies and the level of required care. Column one, medical emergencies that can be treated in a medical office setting and column two medical emergencies that require a higher level of care; such as, ambulance transportation to a hospital. Create a medical office protocol to determine if the emergency requires higher level and the steps for office personal to follow. Mod 5 Assign 1
In Excel, create a 2x30 data table with the left column representing a population of prey...
In Excel, create a 2x30 data table with the left column representing a population of prey and the right column representing a population of predators. Use the population model presented below. Let the starting values of the model parameters be: r = 1.3, k = 1, s = .5, v = 1.6, and u = .7 Let the starting population of P = 1.1 and Q = .4 Difference equations: P[t + 1] = P[t](1 + r(1 – P[t]/K)) -...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT