Professional Documents
Culture Documents
PROGRAMME INFORMATION `
TECHNOLOGY
We can transform the given ER model into a database schema. The following is the schema
with identified primary keys (PK) and foreign keys (FK):
1) Table: Appointments Columns: id (PK), description ,date ,time, patient_id (FK references
patient.id)
2)Table: Patient Columns: id (PK) ,name, address, sex ,age, dob
3) Table: Dues Columns: id (PK), amount, date ,patient_id (FK references patient.id)
4)Table: Test Columns: id (PK), description
5)Table: Clinic Columns: name
6)Table: Doctor Columns: id (PK), name, specialization ,visitinghrs, patient_id (FK
references patient.id)
Relationship: Patient visits Appointment Foreign Key: patient_id (refers to Patient.id)
Relationship: Patient visits Doctor Foreign Key: patient_id (refers to Patient.id)
Relationship: Patient has Dues Foreign Key: patient_id (refers to Patient.id)
Relationship: Patient has Test Junction Table: Patient_Test Columns: patient_id (FK
references patient.id) test_id (FK references test.id)
Relationship: Patient has Test at Clinic
Junction Table:Patient_Test_Clinic
Columns: patient_id (FK references patient.id) ,test_id (FK references test.id), clinic_id (FK
references clinic.id)
In this transformed database schema, the primary keys (PK) are identified with the suffix
"(PK)" and the foreign keys (FK) with the suffix "(FK)" in the table definitions. The
relationships are represented either through direct foreign key references or through junction
tables for many-to-many relationships.
a) Given R (A, B, C, D, E) with the set of FDs, F {AB CD, A E, C D}. Is the
decomposition of R into R1 (A,B,C), R2 (B,C,D) and R3(C,D,E) lossless? Prove.
c) Suppose you are given a relation R = (A,B,C,D,E) with the following functional
dependencies: {CE D,D B,C A}.
ii)If the relation is not in BCNF, decompose it until it becomes BCNF. At each step, identify
a new relation, decompose and re-compute the keys and the normal forms they satisfy. [4]
If X ⊇ Y then X → Y
If X → Y then XZ → YZ
Union rule says, if X determines Y and X determines Z, then X must also determine Y and Z.
If X → Y and X → Z then X → YZ
Proof:
1. X → Y (given)
2. X → Z (given)
3. X → XY (using IR2 on 1 by augmentation with X. Where XX = X)
4. XY → YZ (using IR2 on 2 by augmentation with Y)
5. X → YZ (using IR3 on 3 and 4)
ii)Explain with examples how these rules are important to enforce consistent database states.
[6]
The entity integrity rule is important to enforce consistent database states because it ensures
that each record is unique and can be easily identified. For example, if a customer database
did not have a primary key, it would be difficult to distinguish between two customers with
the same name and address. Primary keys ensure that any prime attribute must not be NULL.
The referential integrity rule is important to enforce consistent database states because it
ensures that data is accurate and reliable. For example, if an order database did not have
referential integrity, it would be possible for an order to be associated with a non-existent
customer or product. Referential integrity ensures that the values in the foreign key must
belongs to it parent key or it may be entirely NULL.
e) Given the dependency diagram shown in the following figure describe each of the
indicated dependencies. [6]