0% found this document useful (0 votes)
5 views2 pages

Database Fundamentals Sample Test

Uploaded by

mohamed9ahmed12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Database Fundamentals Sample Test

Uploaded by

mohamed9ahmed12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Ministry of Communications and information Technology

Information Technology Institute

Database Fundamentals
Sample Test

Question1

Part 1: Answer with Yes or No.


1. (Yes)
2. (NO
3. (NO)
4. (NO)

Part 2: Choose the correct answer


1- (B)
2- (A)
3- (A)
4- (A)

Q 2: Draw an ERD for the following case study:


(Solved By Students)

Q 3: Draw a Logical Schema (Mapping) for the following ERD:

Patient {SSN, DOB, First-name, last-name, Address, Doc_SSN}


Doctor {SSN, Lname, Fname, Specialty, Year-of-exp}
Prescription {ID, Date, Doc_SSN, Patient_SSN, Pharmacy-name}
Drug {Trade-name, Generic-flag, Price}
(Contains)Prescription_Drug{Prescriptipn-ID , Trade-name , Quantity
Pharmacy {Name, Address, Phone, H-Delivery-flag}
(Stores)Pharmacy-Drug {Pharmacy-name, Trade-name, Shelf-no}
Another answer:
(Stores)Pharmacy-Drug {Pharmacy-name, Trade-name, Shelf-no}

1
Ministry of Communications and information Technology
Information Technology Institute

(Question 4) SQL:
Part 1
Q1: D
Q2: C
Q3: C
Q 4: D
Q5: A

(Question5) Normalization:

1NF
1. (Company_ID, Company_Name, Company_Address)
2. (Company_ID, Model_ID, Model_Name, Model_Colour, Selling_Price,
Available_Quantity, Dealer, Dealer_Address)
2NF
1. (Company_ID, Company_Name, Company_Address)
2. (Model_ID, Model_Name, Model_Colour, Dealer, Dealer_Address)
3. (Company_ID, Model_ID, Selling_Price, Available_Quantity)
3NF
1. (Company_ID, Company_Name, Company_Address)
2. (Model_ID, Model_Name, Model_Colour, Dealer)
3. (Dealer, Dealer_Address)
4. (Company_ID, Model_ID, Selling_Price, Available_Quantity)

Common questions

Powered by AI

The 'Generic-flag' attribute distinguishes between generic and brand-name drugs, significantly affecting queries concerning drug prescription patterns or cost analysis. This attribute allows for precise filtering to evaluate prescribing trends or cost-effectiveness, ensuring queries return accurate, relevant data. By incorporating this differentiation, the database can support detailed analyses without conflating distinct types of pharmaceutical products .

SQL queries can be optimized by reducing join operations and ensuring that indices are appropriately created on primary and foreign key fields. For example, the separation of attributes into 1NF and 2NF allows for precise indexing on unique identifiers, minimizing redundancy. Queries are optimized by only selecting relevant columns and employing query plans that utilize these indices efficiently, especially when querying data that spans multiple related tables .

The 'Year-of-exp' attribute specifies the doctor's years of experience, which is crucial for differentiating among doctors with similar names or specialties. It provides additional context for users querying the database, potentially informing decisions related to assigning prescriptions or patient care. This attribute ensures that the entity captures not only identifying information but also subjective qualifications that may impact database interactions .

Normalizing a database to 3NF significantly reduces redundancy by eliminating transitive dependencies, ensuring each non-key attribute is only dependent on primary keys. This not only conserves storage space by preventing duplicate data but also simplifies updates and maintenance by reducing the risk of anomalies during insertions, deletions, or modifications. Dependencies are clearly defined, which enhances data integrity and facilitates efficient data retrieval .

An Entity-Relationship Diagram (ERD) helps visualize the relationships between different entities in a database, allowing for a comprehensive understanding of their interactions. In the presented case study, the ERD outlines the connections between entities such as Patient, Doctor, Prescription, and Drug, illustrating attributes and relationships like the association between doctors and prescriptions written. This visualization aids in identifying how entities are linked and how data flows between them .

Denormalization might be justified in scenarios where performance is prioritized over storage efficiency, such as when high volumes of transactional queries require rapid access to combined data from Doctor, Patient, and Prescription entities. By duplicating data across tables, denormalization can reduce join operations and improve query speed at the cost of increased redundancy and potential anomalies unless carefully managed .

The 'Pharmacy-Drug' relationship is modeled as a separate entity to capture the many-to-many relationship between pharmacies and drugs. Each pharmacy can store multiple drugs, and each drug can be found in multiple pharmacies. By representing this relationship as a separate entity, the database effectively handles various combinations of pharmacies and their available drugs, including additional attributes like shelf numbers. This approach facilitates accurate data representation and retrieval across complex datasets .

In 1NF, the relation is structured such that there are no repeating groups, evidenced by individual records for each attribute set (e.g., each Model_ID having its associated attributes like Model_Name, Model_Colour). In 2NF, partial dependencies are removed, meaning all non-key attributes are fully functionally dependent on the primary key, as demonstrated by separating Model_ID from Company_ID where appropriate. In 3NF, transitive dependencies are eliminated, ensuring that non-key attributes depend only on primary keys, exemplified by the separation of Dealer information from Model attributes .

Converting an ERD to a logical schema can be challenging due to the need to accurately capture intricate relationships without losing data fidelity. Complex medical data relationships, such as those involving multiple prescriptions per patient or varying drug availability across pharmacies, require elaborate mapping to avoid redundancy while ensuring all necessary data points are captured. Ensuring that every entity's constraints and dependencies are properly translated into the logical schema can complicate the design process .

The logical schema enhances data organization and retrieval by translating the ERD into a detailed framework of tables that define data attributes and relationships. For instance, it specifies how a Prescription entity relates to both Doctor and Patient entities by their SSN, enabling precise queries that access interconnected data efficiently. This organization facilitates optimized database operations and ensures data integrity .

You might also like