Question
Asked Nov 20, 2019
10 views

What are the SQL query commands to create the tables (attached) with appropriate attributes and data types together with primary keys, foreign keys, relationships and constraints.

|(1,1)
(0,N)
SCHOOL
DEPARTMENT
H has- <
SCHOOL_CODE
DEPARTMENT ID
PK
DEPARTMENT_ID
FK
DEPARTMENT NAME
(1,1)
employs
(1,N)
PROFESSOR
PROF NUM
PK
DEPARTMENT_ID
FK
PROF LASTNAME
PROF_FIRSTNAME
(1,1)
teaches
help_outline

Image Transcriptionclose

|(1,1) (0,N) SCHOOL DEPARTMENT H has- < SCHOOL_CODE DEPARTMENT ID PK DEPARTMENT_ID FK DEPARTMENT NAME (1,1) employs (1,N) PROFESSOR PROF NUM PK DEPARTMENT_ID FK PROF LASTNAME PROF_FIRSTNAME (1,1) teaches

fullscreen
check_circle

Expert Answer

Step 1

Primary key:

A PRIMARY KEY is used to define each tuple in a table in a unique way. The PRIMARY KEY imposes limits on the credibility of the table that only one PRIMARY KEY in a table can be permitted. The PRIMARY KEY does not permit duplicate or NULL values.

Syntax:

Name_of_column  Data Type PRIMARY KEY;

Foreign key:

A FOREIGN KEY in one table matches the PRIMARY KEY in another table is a field (or a field collection).

Syntax:

FOREIGN KEY (Name_of_column) REFERENCES FOREIGN_KEY_TABLE_NAME(Name_of_column);

Create command:

A new table in a database is created using the CREATE TABLE statement.

Syntax:

CREATE TABLE name_of_table (     first_column datatype,     second_column datatype,     third_column datatype,    .... );

 

Step 2

SQL command to create a table DEPARTMENT which includes DEPARTMENT_ID  as primary key is given below:

CREATE TABLE DEPARTMENT (

    DEPARTMENT_ID    INT PRIMARY KEY,

    DEPARTMENT_NAME  VARCHAR(30)         

);

help_outline

Image Transcriptionclose

Your Database: Tablename Records DEPARTMENT 0

fullscreen
Step 3

SQL command to create a table SCHOOL which includes SCHOOL_CODE  as primary key and DEPARTMENT_ID as foreign key  is given below:

CREATE TABLE SCHOOL (

    SCHOOL_CODE      INT PRIMARY KEY,

    DEPARTMENT_ID    INT , FORE...

help_outline

Image Transcriptionclose

Your Database: Tablename Records 0 DEPARTMENT SCHOOL

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: How did Cisco systems solve physical security problems?

A: Cisco is a US-based technology corporation best known for its networking services. As a company that...

question_answer

Q: Write a program that generates a two-column table showing Fahrenheit temperatures from -40F to 120F ...

A: Java program://Create a class name "temperature"public class temperature{     //Definition for main ...

question_answer

Q: WHAT ARE THE BARRIERS FOR THE ADOPTION OF CRYPTOCURRENCY WORLDWIDE?

A: There are several barriers for the adoption of cryptocurrency worldwide. A few of them are as follow...

question_answer

Q: Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. E...

A: oldScores is an integer type array that stores 4 value.newScores is an integer type array that copy ...

question_answer

Q: What are the components of a function and how do I use it in a program?

A: In programming language there are two types of function one is build in type and the other is user-d...

question_answer

Q: What is the RAND Report? Why was it developed? What was published in the RAND Report R-609?Why was i...

A: RAND Report:RAND reports consist of findings from the profound research and objective analysis which...

question_answer

Q: Create reports containing the following details from the database: Q1 How many books are there in th...

A: SELECT category, count(category) AS "numberOfBooks",FROM booksWHERE category='computer'; The above q...

question_answer

Q: Visit the Web sites of major technology organizations {Microsoft, Oracle, and Cisco), plus two more ...

A: Websites for best security practices Microsoft creates, retains and disposes business records and in...

question_answer

Q: For the given business rule,  is the explanation for relationship and cardinality correct between PR...

A: Explanation for relationshipHere the relationship is PROFESSOR “teaches” COURSE. Business rule state...