Question

In: Computer Science

QUESTION 1 a. What are referential integrity constraints? Please explain with an example. b. Explain with...

QUESTION 1
a. What are referential integrity constraints? Please explain with an example.

b. Explain with an example the GROUP BY/HAVING clause

Solutions

Expert Solution

a.

Referential integrity refers to the accuracy and consistency of data within a relationship.Relationships are those where data is linked together to two or more tables. Foreign key defined during table creation or alteration are used to acheive this relationship by referencing the primary key value of the parent table.Hence it is important to maintain the data in bothsides without any updates or alteration.If done,same is to done on the other side too.

Referential integrity requires a foreign key value which must be referenced to a valid, existing primary key in the parent table.

Example

Let us consider a table with primary key value 1,2,13.If we delete record number 13 in a primary table, we need to make sure that there’s no foreign key in any related table with the value of 13. We should only be able to delete a primary key if there are no associated records or else we would end up with an orphaned record.As a result some unwanted data may be entered to the table which will inversely effect the data integrity.

b.

GROUP BY

Group by close is used to select rows one or more tables having the same values with or without help of some functions.

Syntax:

SELECT column1, function_name(column2) FROM table_name WHERE condition GROUP BY column1, column2 ORDER BY column1, column2;

HAVING

WHERE clause is used to place conditions on columns whereas HAVING is used if we want to place conditions on groups.We can use HAVING clause to place conditions to decide which group will be the part of final result-set. Unlike WHERE clause ,which cannot be used with the aggregate functions like SUM(), COUNT() etc.,HAVING clause,can be used along with these aggragate functions.

Syntax:

SELECT column1, function_name(column2) FROM table_name WHERE condition GROUP BY column1, column2 HAVING condition ORDER BY column1, column2;


Related Solutions

Using a simple relation of your own choice and example, explain Entity Integrity and Referential Integrity.
Using a simple relation of your own choice and example, explain Entity Integrity and Referential Integrity.
5.8. Discuss the entity integrity and referential integrity constraints. Why is each considered important? 5.9. Define...
5.8. Discuss the entity integrity and referential integrity constraints. Why is each considered important? 5.9. Define foreign key. What is this concept used for? 5.10. What is a transaction? How does it differ from an Update operation?
Assuming Database is not providing Referential Integrity Constraints support i-e Primary key, foreign key and Unique...
Assuming Database is not providing Referential Integrity Constraints support i-e Primary key, foreign key and Unique key, your task is to design a database engine with your own built in Referential integrity rules implementation and you need that only one database connection is maintained which an application should access. Recommend proper design pattern used for the stated problem. Give reasons for selecting that pattern, create complete class diagram for the solution. The class diagram should also show the methods of...
Answer these theory questions: a. Explain the referential integrity rule. Provide a suitable situation when the...
Answer these theory questions: a. Explain the referential integrity rule. Provide a suitable situation when the referential integrity constraint is violated. b. Consider a relation named STUDENT_ ACCOMMODATION (StudentID, Buidling, AccommodationFee) as shown in the figure below. Explain why this relation is in 2NF but not in 3NF.              StudentID Building AccommadtionFee 101 Alpha $320 102 Betta $250 103 Alpha $320 104 Betta $250 105 Gemma $400 c. Explain the purpose of transaction logs and checkpoints. d. Compare and contrast Data...
What would you do if you encountered a database that violated referential integrity? How would you...
What would you do if you encountered a database that violated referential integrity? How would you address the problem? When forming your answer be sure to include at least one of the three main types of referential actions (cascade, restrict, set null).
Please explain and describe the question above with an example. 1. Free Cash Flow (Explain and...
Please explain and describe the question above with an example. 1. Free Cash Flow (Explain and describe) 2. Define the dividends to the investor versus cash flow 3. What is different between Nominal and Real Cash flow
Explain what academic integrity is, and explain how you are prepared to meet the academic integrity...
Explain what academic integrity is, and explain how you are prepared to meet the academic integrity standards at your nursing school
ESSAY QUESTION> PLEASE BE VERY CONSTRUCTIVE 1.a) Explain the 2008-2009 recession. b) what caused it, what...
ESSAY QUESTION> PLEASE BE VERY CONSTRUCTIVE 1.a) Explain the 2008-2009 recession. b) what caused it, what happened with the housing market and banking system, and how did policy makers (the gov. and Fed) try to fix it/why was it hard to fix?
1) Which of the following is an example of how the integrity of certain types of...
1) Which of the following is an example of how the integrity of certain types of clinical specimens can be maintained? Select any that apply. Select more than one: a. None of these. b. Keeping a sample within a specific temperature range. c. Keeping air out of a sample. d. Keeping foil over a sample. 2) What does mycology testing detect? Select one: a. Mold b. Bacteria c. None of the above d. Parasites e. Viruses 3) At what stage...
****Please clearly explain what target objective, changing cells and constraints are taken for the solution********* A...
****Please clearly explain what target objective, changing cells and constraints are taken for the solution********* A political candidate has an advertising budget of $250,000. The candidate wishes to allocate the advertising money among four media outlined in the table below. The candidate's goal is to reach the largest possible audience. To ensure the candidate reaches a diverse audience, the table also displays a minimum and maximum level of ads that should be placed. Use Excel's solver to assist the candidate...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT