Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use MICROSOFT SQL SERVER language to fill the block like (...) Here is the diagram 1)Create a new view on table Category. There should be

Use MICROSOFT SQL SERVER language to fill the block like (...)

Here is the diagram

image text in transcribed

1)Create a new view on table Category. There should be two columns in the view: the name of the category and the name of the parent category (or null if it does not exist)

create view CategoryParentVW

as

select..................... write here you code

left outer join ..................... write here you code

2)Create a triggerthat allows insertinga new category through the view. If the parent category is null, throw an exception and exit. image text in transcribed

3)Test the trigger. The solution contains the commands for the test and the results as well.

Try it without a parent category

insert into..................... write here you code

... and with parent category

insert into ..................... write here you code

.... finally with an erroneous parent

insert into ..................... write here you code

4)Modify the table Invoice, add a new column to store the sum of all items of the invoice. (e.g. two balls and one pen are 3 items)

alter table Invoice (Invoice)

..................... write here you code

5)Create a T-SQL block to fill up the new column based on the data stored.

update Invoice

set ..................... write here you code

6)Create a trigger that can update the ItemNum field automatically.

image text in transcribed

7)Test the trigger. The command, the expected and the real results should be documented.

update InvoiceItem

set ..................... write here you code

Payment Method Order ID 9 ID Date Method Deadline PlaceOfBusiness ID Zip Code City Street Deadline PlaceOfBusinessID StatusID Payment Methodid Customer Y ID Name BankAccount Login Password Email MainPlaceOfBusiness Fax Customer Status 8 ID Name Invoicelssuer 9 ID Orderltem ID Amount Price Order D ProductiD StatusID Category 9 ID Invoice* Y ID CustomerName CustomerZipCode Customer City Customer Street PrintedCopies Cancelled Payment Method CreationDate DeliveryDate Payment Deadline InvoicelssuerlD Order Name ZipCode City Street Taxidentifier BankAccount Name ParentCategory Product VAT Y ID Name Invoiceltem Price Percentage Name Amount InStock VATID CategoryID Description Image Price VATPercentage InvoicelD OrderitemID create trigger CategoryParentTG on CategoryParentVW instead of insert as begin declare @newName nvarchar(255) declare @parentName nvarchar(255) declare ic cursor for select * from inserted open ic fetch next from ic into @newName, @parentName while @@FETCH_STATUS = 0 begin declare parentid int if @parentName is not null begin (..... .....) write here you code end (.............) write here you code end close ic deallocate ic end create trigger Invoice ItemNumTG on Invoiceltem after insert, update, delete as begin update Invoice set itemNum = ItemNum + change from Invoice inner join (.....................) write here you code update Invoice set itemNum = ItemNum - change from Invoice inner join (.....................) write here you code end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data And Hadoop Fundamentals Tools And Techniques For Data Driven Success

Authors: Mayank Bhushan

2nd Edition

9355516665, 978-9355516664

More Books

Students also viewed these Databases questions

Question

c. Supply increases and demand is constant.

Answered: 1 week ago