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...
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
Consider the following contingency table that is based on a sample survey. Column 1 Column 2...
Consider the following contingency table that is based on a sample survey. Column 1 Column 2 Column 3 Row 1 136 90 83 Row 2 96 54 88 Row 3 125 75 110 a. Write the null and alternative hypotheses for a test of independence for this table. H 0 : Rows and columns are ; H 1 : Row and columns are . b. Calculate the expected frequencies for all cells assuming that the null hypothesis is true. Round...
Consider the following contingency table that is based on a sample survey. column 1 column 2...
Consider the following contingency table that is based on a sample survey. column 1 column 2 column 3 row 1 137 86 77 row 2 93 51 86 row 3 126 76 112 a. Write the null and alternative hypotheses for a test of independence for this table. H0: Rows and columns are: Independent or dependent H1: Rows and columns are: Independent or dependent b. Calculate the expected frequencies for all cells assuming that the null hypothesis is true. Round...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT