Question

mvLPscreen(model, speed, ram, size, cost) A materialized view is not supported in MySQL. However, it is...

mvLPscreen(model, speed, ram, size, cost)

A materialized view is not supported in MySQL. However, it is possible to create a substitute with the same behavior by first creating a relation with one or more queries and then creating triggers to maintain the table when inserts, updates, and deletions occur.

For example, if we want a "materialized view" of laptops with screens at least 17 inches, we start by creating a new relation:

CREATE TABLE mvLPscreen AS SELECT * FROM laptop WHERE screen >= 17;

This creates a new relation and populates it with the results of our query. The problem in new relation is that it is static. If laptop relation changes the fake materialized view will not change. We can use triggers, one to handle inserts, one for updates, one for deletes. The triggers should make the corresponding change to the fake materialized view relation.

Demonstrate the correctness of your fake materialized view with a combination of select, insert, update, and delete queries on the laptop relation.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. DELETE FROM laptop WHERE screen=18;

SELECT * FROM mvLPscreen WHERE screen=18; This query would return a set of rows.

SELECT * FROM laptop WHERE screen=18; This query returns NULL. This shows the inconsistency in our view.

2. UPDATE laptop SET cost=0 WHERE screen=19;

SELECT cost FROM mvLPscreen WHERE screen=19; This would return values other than zero.

SELECT cost FROM laptop WHERE screen=19; This would return all rows value as 0.

IF you want the triggers and then the queries to show correctness of triggers, Please mention in the comment and I would edit the anwer.

Add a comment
Know the answer?
Add Answer to:
mvLPscreen(model, speed, ram, size, cost) A materialized view is not supported in MySQL. However, it is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Learning Objectives: Learn to define constraints on tables Lean to define primary keys and foreign keys...

    Learning Objectives: Learn to define constraints on tables Lean to define primary keys and foreign keys Exercise                                                                                In Lab 09, we will continue the practice of creating tables. You will need to write SQL statements for the tasks specified below. After you complete them, submit your SQL script (in one *.sql file) to Blackboard by 11:59pm Nov. 16 (Friday). Include your name as a comment in the SQL script submitted. The creation statement for each table is worth one point,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT