Question

In: Computer Science

PROBLEM 3: Given the following relational database table: Patients(ID, name, symptom, days_in_hospital) The following insertions are...

PROBLEM 3: Given the following relational database table: Patients(ID, name, symptom, days_in_hospital) The following insertions are performed on the table Patients: Insert record <20, Johnson, cough, 3> Insert record <10, Black, fever, 5> Insert record <30, Miller, fever, 10> Insert record <70, Brown, fatigue, 2> Insert record <60, Grant, headache, 4> Insert record <50, Miller, nausea, 15> Insert record <90, Brown, cough, 8 > Assume each block in the Patients file can store up to 2 patient records. Do the following: 1. Assuming that Patients is organized as a heap file, show the contents of the file after the last insertion. 2. Assuming that Patients is organized as a sequential file with days_in_hospital as the ordering field, show the contents (i.e. the data values as well as the associated block/bucket/record addresses) of the file after the last insertion. 3. Assuming that Patients is organized as an index-sequential file on the search key days_in_hospital and assuming that the primary index, the secondary index on ID, and the secondary index on name have been created, show the contents of Patients, the primary index, and the two secondary indices after the last insertion. 4. Given the index-sequential file organization as described in (3), explain step-by-step how the DBMS would conduct search on this file organization to answer the following SQL query: select name from Patients where ID between 30 and 60

Solutions

Expert Solution

1) INSERT INTO PATIENTS (ID, name, symptoms, days_in_hospital)

values (20, Johnson, cough, 3)

INSERT INTO PATIENTS (ID, name, symptoms, days_in_hospital)

values (10, Black, fever, 5)

INSERT INTO PATIENTS (ID, name, symptoms, days_in_hospital)

values (30, miller, fever, 10)

INSERT INTO PATIENTS (ID, name, symptoms, days_in_hospital)

values (70,Brown , fatigue, 2)

INSERT INTO PATIENTS (ID, name, symptoms, days_in_hospital)

values (60, Grant, headache, 4)

INSERT INTO PATIENTS (ID, name, symptoms, days_in_hospital)

values (50, miller, nausea, 15)

INSERT INTO PATIENTS (ID, name, symptoms, days_in_hospital)

values (90, Brown, cough, 8) ;

table PATIENTS

ID name symptoms days_in_hospital
20 Johnson cough 3
10 Black fever 5
30 Miller fever 10
70 Brown fatigue 2
60 Grant headache 4
50 Miller nausea 15
90 Brown cough 8

SELECT NAME

FROM PATIENTS

WHERE ID BETWEEN 30 AND 60;

NAME
Miller

the sql query selects name of patient from patient table whose ID ranges between 30 and 60 even after going through the assumptions given.


Related Solutions

Consider the following relational database schema:             employee(employee-name, employee-id, street, e-city)             works(employee-
Consider the following relational database schema:             employee(employee-name, employee-id, street, e-city)             works(employee-id, company-id, salary)             company(company-name, company-id, c-city)             manages(employee-id, manager-id) Specify the following queries on this database schema using the relational operators we discussed in class. Write your answers on a separate sheet of paper in the order that they are specified below. Retrieve the name and address of employees who work for First Bank Corporation. Retrieve the name, street address, and city of residence of all employees...
Student Name and ID no. _________________________________________________________ Write the journal entries in the given table for below...
Student Name and ID no. _________________________________________________________ Write the journal entries in the given table for below transactions of Clean Corporation during June 2020. 1 Provided services to customers on account for $650. 2 Purchased a building using 10 year Note Payable for $200,000. 3 Paid salaries to employees, $2,600. 4 Received payment from customers to whom service was given in transaction 1 5 Paid $400 dividends to shareholders. Answer Accounts Debit Credit 1 2 3 4 5
mySQL database question.. I have a database that has the following tables: User (Id, Name, Gender)...
mySQL database question.. I have a database that has the following tables: User (Id, Name, Gender) Primary key = Id Friends (Id1, Id2, Startdate) Primary key = (Id1, Id2) Foreign keys are also Id1, Id2 pointing to User(Id) Comments (CommentId, Poster, Recipient, Text, PostDate) Primary key = (CommentId) Foreign Keys are Poster, Recipient pointing to User(Id) I need to answer the following queries: 5. List Users who have posted comments to all female users 6. List User(s) who have received...
tableA is a table in a relational database with a composite prime key consisting of fields...
tableA is a table in a relational database with a composite prime key consisting of fields F1 and F2. You have determined that tableA is 1NF. There are four other fields in tableA. Two of them, F10 and F12, are functionally determined by F1. The other two, F50 and F55, are functionally determined by F2. Because all fields are functionally determined by at least a portion of the key, is tableA 2NF?   If you believe the table is not yet...
What is the relationship between a table of Movies and a table of ActorsActresses and how might it be implemented in a relational database?
What is the relationship between a table of Movies and a table of ActorsActresses and how might it be implemented in a relational database?
Given a relational database that consists of the following relations: Performer (pid: integer, pname: string, years_of_experience:...
Given a relational database that consists of the following relations: Performer (pid: integer, pname: string, years_of_experience: integer, age: integer) Movie (mname: string, genre: string, minutes: integer, release_year: integer, did: integer) Acted (pid: integer, mname: string) Director (did: integer, dname: string, earnings: real) Do the following using your Azure SQL database: a) Use SQL statements to create the relations. b) Populate the relations using SQL statements with the given data posted on Canvas. c) Implement the SQL queries for the following:...
tableA is a table in a relational database with a composite prime key. You have determined...
tableA is a table in a relational database with a composite prime key. You have determined that the table is 2NF. Owing to the fact that it is 2NF and the key is composite, is it automatically 3NF? Explain your answer. (4 points) Lack of normalization of database tables may cause update, delete, and/or insert anomalies. You have a 2NF table, tableA, in a relational database. Give an example of an anomaly to which tableA might still be subject. Give...
Database - Relational Theory The state of a table or relation relates to its current content....
Database - Relational Theory The state of a table or relation relates to its current content. Consider the formal terminology of the relational model. 1) Which descriptive term of a relation applies to the state of a relation? 2) Which descriptive term of a relation is not affected a change in the state of the relation? 3) In addition to identifying these terms, provide a brief definition of each of term.
Create a table ‘StudentInfo’ with following fields: ID First Name Last Name SSN Date of Birth...
Create a table ‘StudentInfo’ with following fields: ID First Name Last Name SSN Date of Birth Create a table ‘ClassInfo’ table: ID Class Name Class Description Create a table ‘RegisteredClasses’ table: StudentID ClassID The RegisteredClasses table should have a foreign key relationship to StudentInfo and ClassInfo tables for the respective IDs. Also the IDs in StudentInfo and ClassInfo need to be primary keys. When you submit the file your email should also contain the following SQL Queries: Query to show...
We plan to develop customer’s database that stores customer’s number (ID), first name, last name and...
We plan to develop customer’s database that stores customer’s number (ID), first name, last name and balance. The program will support three operations: (a) reading and loading customer’s info from the text file, (b) entering new customer’s info, (c) looking up existing customer’s info using customer’s number(ID), (d) deleting the customer’s info and (e) the updated database will be stored in the text file after the program terminate. Customer’s database is an example of a menu-driven program. When the program...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT