- Input: Date
- Output: Month Name of that date
- Input: 2 Integers
- Output: All values between them
- Input: Student No
- Output: Full Name + Department Name
- Input: Student ID
- Logic:
- If First + Last Name = NULL → "First name & last name are null"
- If First Name = NULL → "first name is null"
- If Last Name = NULL → "last name is null"
- Else → "First name & last name are not null"
- Input: Integer format code
- Output: Department Name + Manager Name + Hire Date in format
- Input: String
- Output:
- "first name" → Student First Name
- "last name" → Student Last Name
- "full name" → Student Full Name (use ISNULL)
- Input: Project Number
- Output: All employees in this project
- View – Student Full Name + Course Name where Grade > 50
- Encrypted View – Instructor Name + Topic Name
- View with Schema Binding – Instructor Name + Department for "Java"/"SD"
- View
V1– Students from Alex/Cairo- Prevent:
UPDATE V1 SET st_address='tanta' WHERE st_address='alex'
- Prevent:
- View – Project Name + Number of Employees in each
- View
v_clerk– Emp#, Project#, Hire Date for all Clerks - View
v_without_budget– All project data (no budget column) - View
v_count– Project Name + Number of Jobs in it - View
v_project_p2– Emp# for project 'p2' (usingv_clerk) - Modify
v_without_budget– Show data forp1+p2 - Delete Views:
v_clerk,v_count - View – Emp# + Last Name for deptNumber = 'd2'
- Filter Last Names with letter "J" using view from Q#7
- View
v_dept– Dept# + Dept Name - Insert into
v_dept– Dept# = 'd4', Name = 'Development' - View
v_2006_check– Emp#, Project#, Enter_Date in 2006 only- Allow only inserts that match this condition
| DeptNo | DeptName | Location |
|---|---|---|
| d1 | Research | NY |
| d2 | Accounting | DS |
| d3 | Marketing | KW |
➡ Create programmatically with DeptNo as Primary Key
Fields:
- EmpNo (PK)
- EmpFname (NOT NULL)
- EmpLname (NOT NULL)
- DeptNo (FK to Department.DeptNo)
- Salary (UNIQUE)
➡ Constraints:
- PK on
EmpNo - FK on
DeptNo - UNIQUE on
Salary EmpFname,EmpLnameNOT NULL
| ProjectNo | ProjectName | Budget |
|---|---|---|
| p1 | Apollo | 120000 |
| p2 | Gemini | 95000 |
| p3 | Mercury | 185600 |
➡ Create using wizard
ProjectNameNOT NULLBudgetallows NULL
Fields:
- EmpNo (PK, FK to Employee)
- ProjectNo (PK, FK to Project)
- Job (NULL allowed)
- Enter_Date (NOT NULL, default = GETDATE())
➡ Notes:
- Composite Primary Key: (
EmpNo,ProjectNo) Enter_Datehas default system date (set visually)- Has FK to both
EmployeeandProject
- Try inserting EmpNo = 11111 in
works_onwithout existing inemployee→ ❌ Fails - Change
EmpNoinworks_onfrom 10102 to 11111 → ❌ FK violation - Change
EmpNoinemployeefrom 10102 to 22222 → ❌ Affectsworks_onif no cascading - Delete
EmpNo = 10102fromemployee→ ❌ Error if referenced
- ➕ Add column:
ALTER TABLE Employee ADD TelephoneNumber VARCHAR(20);
If you'd like to use the IKEA_Company_DB for practicing the Views section, you can download it from the link below: