Hello guys, I created a Database as follows, what I need to do is anytime an item is ordered, the quantity should be deducted accordingly on the Rentals.Products table, from what I read, the ON UPDATE CASCADE only makes any changes that were made in the parent table and reflects them in the child table, but how can you do vice versa ? or what is the best solution to get this job done? thanks in advance.
CREATE TABLE Rentals.Members ( MemberID int NOT NULL CONSTRAINT PK_Members_MemberID PRIMARY KEY, Name nvarchar(50), [Address] nvarchar(100) ); GO CREATE TABLE Rentals.Products ( ProductID int NOT NULL CONSTRAINT PK_Products_ProductID PRIMARY KEY, CategoryType varchar(30), ProductName varchar(100), Price numeric(10,2), Quantity numeric(10,2) NULL CONSTRAINT DF_Products_Quantity DEFAULT(0) ); GO CREATE TABLE Rentals.Sales ( SalesOrderID int IDENTITY(1,1) NOT NULL CONSTRAINT PK_Sales_RentID PRIMARY KEY, MemberID int NOT NULL CONSTRAINT FK_Members_MemberID FOREIGN KEY REFERENCES Rentals.Members (MemberID), ProductID int NOT NULL CONSTRAINT FK_Products_ProductID FOREIGN KEY REFERENCES Rentals.Products (ProductID) ON DELETE CASCADE, Quantity numeric(10,2) NULL CONSTRAINT DF_Sales_Quantity DEFAULT(0), RentalPeriod numeric(2) NULL, RentDate datetime CONSTRAINT DF_Sales_RentDate DEFAULT GETDATE(), );