Question

In: Computer Science

Consider the following schema: Student(id, name) Registration(id, code) Course(code, instructor) A) Explain how we can violate...

Consider the following schema:
Student(id, name)
Registration(id, code)
Course(code, instructor)

A) Explain how we can violate the foreign key constraint from the id attribute of Registration to the Student relation.  
Ans.

B)Give the following queries in the relational algebra.

1)What are the names of students registered in IT244?   
Ans.


2 )What are the names of students registered in both IT244 and CS141?
Ans.                                

3)What are the names of students who are taking a subject not taught by Philips?
Ans.                            

C )For each of the following relational algebra queries, write in English what they mean.
1. Πinstructor (σcode=IT446 or code=IT230(Course))       
Ans.


2. Πname (σcode=IT446 (Student ⋈ Registration)) ⊔ Πname (σcode=IT441(Student ⋈ Registration))                      

Ans.

Solutions

Expert Solution

A)
Ans. If id attribute in Registration exists and it does not match with any id in the Student table , it violates foreign key constraint. Also if the value of id in Registration table is null it also violates foreign key constraint

B)Give the following queries in the relational algebra.

1)
Ans.

Πnamecode='IT446' (Student Registration))       


2 )
Ans.

Πnamecode='IT446' or code = 'CS141' (Student Registration))                                    

3)
Ans.

      Πnameinstructor != 'Philips'(Student Registration Course))                        

C )For each of the following relational algebra queries, write in English what they mean.
1.
Ans. What are the name of instructors who teach course IT446 or course IT230


2.   

Ans. What are the name of students who have register for the Course IT446 and Course IT441

Do ask if any doubt. Please upvote.


Related Solutions

schema: Student( studID, name, major )   // dimension table, studID is key Instructor( instID, dept );  ...
schema: Student( studID, name, major )   // dimension table, studID is key Instructor( instID, dept );   // dimension table, instID is key Class( classID, univ, region, country );   // dimension table, classID is key Took( studID, instID, classID, score );   // fact table, foreign key references to dimension tables Write a SQL query to find all students who took a class from an instructor not in the student's major department and got a score over 80. Return the student name,...
Consider the following relational database schema:             employee(employee-name, employee-id, street, e-city)             works(employee-
Consider the following relational database schema:             employee(employee-name, employee-id, street, e-city)             works(employee-id, company-id, salary)             company(company-name, company-id, c-city)             manages(employee-id, manager-id) Specify the following queries on this database schema using the relational operators we discussed in class. Write your answers on a separate sheet of paper in the order that they are specified below. Retrieve the name and address of employees who work for First Bank Corporation. Retrieve the name, street address, and city of residence of all employees...
Relation : course(course id, title, dept name, credits) Explain how to create different indices: primary index,...
Relation : course(course id, title, dept name, credits) Explain how to create different indices: primary index, secondary index, dense index, sparse index, respectively. Using above relation, you can either describe based on the definition of the indices or answer with the instance of the relation using some fake data/tuples.
Code in Java Write a Student class which has two instance variables, ID and name. This...
Code in Java Write a Student class which has two instance variables, ID and name. This class should have a two-parameter constructor that will set the value of ID and name variables. Write setters and getters for both instance variables. The setter for ID should check if the length of ID lies between 6 to 8 and setter for name should check that the length of name should lie between 0 to 20. If the value could not be set,...
11) Enter the following using Java. Use for loop to enter student id, student name, major...
11) Enter the following using Java. Use for loop to enter student id, student name, major and grades. Also grades should display their letter grades based on their conditions. After that display the name of students and their info, and also their letter grade After that display the sum of all grades and the average Output Example: Student ID: 0957644 Student Name: Pedro Hernandez Student Major: Business Information Systems Grades for Fall 2020: Introduction to Computer Science using Java: 85,...
COURSE : IT Enterprise systems Consider the Relations below STUDENT Student# Std-Name Address 1 Smith Jeddah...
COURSE : IT Enterprise systems Consider the Relations below STUDENT Student# Std-Name Address 1 Smith Jeddah 2 Bob Buraidah 3 Alice Dammam COURSE Student# Course Code Course-Name 1 IT241 Operating System 2 IT210 Computer Network 2 IT445 Decision Support System Write a query using the Right Outer Join to retrieve the record from the two relations. Also, construct the table displaying the output of your query. note: NEED A UNIQUE ANSWER AND NO HANDWRITING PLEASE.. THANK YOU
Consider the following relation AIRLINE TABLE Flight Date Flight ID Origin Destination Captain ID Captain Name...
Consider the following relation AIRLINE TABLE Flight Date Flight ID Origin Destination Captain ID Captain Name Number of Passengers on the Flight April 10 111 Chicago L.A. 111 Tracy 110 April 10 222 L.A. Phoenix 222 Matt 105 April 12 111 Chicago L.A. 444 Tim 98 April 12 333 L.A. N.Y. 111 Tracy 75 April 12 444 L.A. N.Y. 333 Pat 110 April 12 555 L.A. Dallas 444 Tim 111 April 12 222 L.A. Phoenix 555 Pat 107 Some of...
Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition,...
Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition, price), PK: ISBN, FK: published_by refs Publisher, previous_edition refs Book. Author (SSN, first_name, last_name, address, income), PK: SSN. Write (aSSN, bISBN), PK: (aSSN, bISBN), FK: aSSN refs Author, bISBN refs Book. Editor (SSN, first_name, last_name, address, salary, works_for, book_count), PK: SSN, FK: works_for refs Publisher. Edit (eSSN, bISBN), PK: (eSSN, bISBN), FK: eSSN refs Editor, bISBN refs Book. Author_Editor (aeSSN, hours), PK: aeSSN, FK:...
Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition,...
Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition, price), PK: ISBN, FK: published_by refs Publisher, previous_edition refs Book. Author (SSN, first_name, last_name, address, income), PK: SSN. Write (aSSN, bISBN), PK: (aSSN, bISBN), FK: aSSN refs Author, bISBN refs Book. Editor (SSN, first_name, last_name, address, salary, works_for, book_count), PK: SSN, FK: works_for refs Publisher. Edit (eSSN, bISBN), PK: (eSSN, bISBN), FK: eSSN refs Editor, bISBN refs Book. Author_Editor (aeSSN, hours), PK: aeSSN, FK:...
The following 3 instances of code was provided by my embedded systems course. Can you explain...
The following 3 instances of code was provided by my embedded systems course. Can you explain what is happening in each code segment? === code 1 === void foo() { uint8_t a=2; uint8_t b[]={b0, b1, b2}; // They are the last three digits of your A# uint8_t* c=b; uint8_t* d=&a; } === code 2 === __extension__ typedef struct tagT1CONBITS { union { struct { unsigned :1; unsigned TCS:1; unsigned TSYNC:1; unsigned :1; unsigned TCKPS:2; unsigned TGATE:1; unsigned :6; unsigned TSIDL:1;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT