Suppose there are two relations r and s, such that the foreign key B of r references the
primary key A of s. Describe how the trigger mechanism can be used to implement
the on delete cascade option, when a tuple is deleted from s.
Of the data type text, number, or yes/no which would be the appropriate for a phone number field that need to store data in the format (123)555-7890? Explain your answer.
ii) Write an SQL query that returns the titles of articles authored by 'Robert Tarjan'.
b) Consider the relations Authors(auID,name) and Authoring(articleID,authorID), containing
information on names of authors, and who is authoring which papers, respectively.
i) Write an SQL query that returns for each article, its ID, title and the number of authors.
ii) Write an SQL query that returns the titles of articles authored by 'Robert Tarjan'.
iii) Write an SQL query that returns the number of co-authors of 'Robert Tarjan'. (I.e., the number of
authors who have written at least one article together with him.)
b) Consider the relations Authors(auID,name) and Authoring(articleID,authorID), containing
information on names of authors, and who is authoring which papers, respectively.
i) Write an SQL query that returns for each article, its ID, title and the number of authors.
ii) Write an SQL query that returns the titles of articles authored by 'Robert Tarjan'.
iii) Write an SQL query that returns the number of co-authors of 'Robert Tarjan'. (I.e., the number of
authors who have written at least one article together with him.)
a) Write SQL commands
1. To create the above table structure with proper constraints.
2. Select all the PROG type published by BPB from Library.
3. Display a list of all books with Price more than 130 and sorted by Qty.
4. Display all the books sorted by Price in Ascending Order.
5. Display a report. Listing Book No. current value and misplacement charges for each book in the above
table. Calculate the misplacement charges for all books Price*1.25
6. Count the number of books published by PHI
7. Insert a new book in the library.
8. Count the no of books in each Type.
9. Add one more attribute “No_of_copies” in the above table.
10. Update the new attribute value with 2 for each book.
11. Count the total number of Publishers.
Consider the relations Authors(auID,name) and Authoring(articleID,authorID), containing
information on names of authors, and who is authoring which papers, respectively.
i) Write an SQL query that returns for each article, its ID, title and the number of authors.
ii) Write an SQL query that returns the titles of articles authored by 'Robert Tarjan'.
iii) Write an SQL query that returns the number of co-authors of 'Robert Tarjan'. (I.e., the number of
authors who have written at least one article together with him
Write an SQL query that returns for each article, its ID, title and the number of authors.
You are searching for information on the cellphone suppliers Vodacom and Cell C excluding MTN. What would you type into a database search to find the most relevant sources for your topic?
a.
Vodacom AND Cell C AND MTN
b.
Vodacom OR Cell C AND MTN
c.
Vodacom OR Cell C NOT MTN
d.
Vodacom AND Cell C NOT MTN
Show only students whose first letter of the name does not begins between A to M, show the Gender column and change the value to Female.
Name Gender
Stephanie N. Female
Tian En Female
Xi Xi Female