Greetings, Refering to Book Concepsts of Database Management Eighth Edition: Cha
ID: 3740155 • Letter: G
Question
Greetings, Refering to Book Concepsts of Database Management Eighth Edition: Chapter 4, Problem 6 & 11 SCG.
My teacher made a few adjustments and I need help with 6&11:
6. For the condo fee field, name the integrity constraint "CK_CondoFee" and for the number of bedrooms the constraint "CK_Bedrooms" (you may do this by writing and executing SQL statements in the "Query Designer" window in which case you should add those statements to the Microsoft Word document, or by creating them in the SQL Server "Table Designer" window--however for full credit on this assignment you must write the SQL statements)
11. Name this stored procedure "UpdateRentalFee"; create and use parameters (arguments) for the CondoID and CondoFee fields; once it is saved copy the text from the "Stored Procedure" . (Keep in mind my class is using Visual Studios.) Please use SQL format when answering. Thank you.
Explanation / Answer
6.
If table is not created then we can define constrains at the column level
Types of constraint:
Primary Key
Not Null
Unique
Check
Foreign Key
Depending on which type of constraint you want need to change type.
CREATE TABLE CK_CONDO
( Condoid int NOT NULL PRIMARY KEY,
CondoFee int CONSTRAINT CK_CondoFee NOT NULL,
NoofBedrooms int CONSTRAINT CK_Bedrooms NOT NULL
);
If Table is already created:
ALTER TABLE CK_CONDO ADD CONSTRAINT CK_CondoFee
CHECK (CondoFee>0);
ALTER TABLE CK_CONDO ADD CONSTRAINT CK_Bedrooms
CHECK (NoofBedrooms>0);
11.
CREATE OR REPLACE PROCEDURE UpdateRentalFee(t_condoid OUT NUMBER, t_condofee OUT NUMBER)
IS
BEGIN
SELECT condoid INTO t_condoid FROM CK_CONDO;
SELECT condofee INTO t_condofee FROM CK_CONDO;
END;
/
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.