Employee Table
EmployeeID |
EmployeeName |
Address |
Phone |
100 |
Ali |
10/125 Egaela |
965224413 |
110 |
Samar |
25/12 Mahboula |
965344917 |
116 |
Noura |
20/15 Hawali |
965222614 |
Payment Table
PaymentID |
EmployeeID |
OvertimePayment |
DateOfPayment |
001 |
110 |
220 KD |
17/12/2021 |
006 |
116 |
100 KD |
10/01/2021 |
007 |
110 |
120 KD |
11/01/2021 |
1)
Identify the Primary keys and foreign keys for each table. (30
points)
Answer: - In EmployeeTable
Primary key = EmployeeID
Foreign keys - not available.
In PaymentTable Primary key = PaymentID
Foreign keys = EmployeeID.
2)
What are the data types for “PaymentID” and “OvertimePayment” in
the Payment table? You should use appropriate data type and length. (20 points)
Answer: - Data types for PaymentID
is Number (3).
And for OvertimePayment
is Text (10).
3)
Is it possible to add the below record to the Employee table?
Explain Why? (15 points)
106 |
Khalid |
215/10 Hawali |
965255891 |
Answer- We
can add this record in the Employee
table Because it is not violating primary key entity integrity principle.
4)
Is it possible to add the below record to the Employee table?
Explain Why? (10 points)
116 |
Ali |
215/10 Hawali |
965356841 |
Answer:
- We can’t add this record in the Employee
table. Because
EmployeeID 116 is available in table
and this is violating entity integrity principle. primary key cannot be
duplicate.
5)
Is it possible to add the below record to the Payment table?
Explain Why? (10 points)
008 |
115 |
300 KD |
13/01/2021 |
Answer:
- We can’t add this record in the Payment
table. Because
EmployeeID is a foreign key and 115
is not available in reference table Employeetable . This is violating Referential
integrity principle that’s by it is not possible to insert this record.
6)
Is it possible to add the below record to the Payment table?
Explain Why? (15 points)
009 |
110 |
120 KD |
14/01/2021 |
Answer- We
can add this record in the Payment table. Because it is not violating entity
integrity principles and foreign key can be duplicate and null in the table.so
we can insert this record.
Post a Comment
Post a Comment