Question

In: Computer Science

Database exercise: inpatient cases Create database using name RUMKIT Create tables below in that database patient(idPatient,...

Database exercise: inpatient cases

  • Create database using name RUMKIT
  • Create tables below in that database
  • patient(idPatient, fullName, biologicalMother, birthdate, address)
  • doctor(idDr, fullName, specialization, consulRates)
  • inpatient(idPatient, entryTime, outTime, idDr, idRoom). Please make entryTime as column that is going to be filled automatically when care record is being add
  • room(idRoom, roomName, cost)
  • fill the data above to each table
  • Create sql query and relational algebra expressions for the query

Please give me detailed answer so I could learn from it. Thank you very much

Solutions

Expert Solution

MySQL queries for inpatient cases

The CREATE DATABASE statement is used to create a new SQL database.

Syntax

CREATE DATABASE databasename;

CREATE DATABASE RUMKIT;

The CREATE TABLE statement is used to create a new table in a database.

Syntax

CREATE TABLE table_name(

   column1 datatype,

   column2 datatype,

   column3 datatype,

   .....

   columnN datatype,

   PRIMARY KEY( one or more columns )

);

The PRIMARY KEY constraint uniquely identifies each record in a table.Primary keys must contain UNIQUE values, and cannot contain NULL values.

A table can have only ONE primary key; and in the table, this primary key can consist of single or multiple columns (fields).

o patient(idPatient, fullName, biologicalMother, birthdate, address)

CREATE TABLE patient(

   idPatient int NOT NULL,

   fullname varchar(100),

   biologicalMother varchar(100),

birthdate date,

   address varchar(200),

   PRIMARY KEY(idPatient)

);

o doctor(idDr, fullName, specialization, consulRates)

CREATE TABLE doctor(

   idDr int NOT NULL,

   fullname varchar(100),

   specialization varchar(100),

consulRates int,

   PRIMARY KEY(idDr)

);

o inpatient(idPatient, entryTime, outTime, idDr, idRoom). Please make entryTime as column that is going to be filled automatically when care record is being add

CREATE TABLE inpatient(

   idPatient int,

   entryTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

   outTime TIMESTAMP,

idDr int,

   idRoom int,

   PRIMARY KEY(entryTime),

   FOREIGN KEY (idPatient) REFERENCES patient(idPatient),

   FOREIGN KEY (idDr) REFERENCES doctor(idDr),

   FOREIGN KEY (idRoom) REFERENCES room(idRoom)

);

o room(idRoom, roomName, cost)

CREATE TABLE room(

   idRoom int NOT NULL,

   roomName varchar(100),

cost int,

   PRIMARY KEY(idRoom)

);

The INSERT INTO statement is used to insert new records in a table.

SYNTAX

INSERT INTO table_name VALUES (value1, value2, value3, ...);

Inserting values into the patient table

INSERT INTO patient
VALUES (30001, samyuktha, Catherine, 2002-10-11,third cross mumbai);

INSERT INTO patient
VALUES (30002, rosy, marry louise, 2004-08-07,patel avenue mumbai);

INSERT INTO patient
VALUES (30003, samskruthi, poonam, 2000-11-01,saradhamma apartment mumbai);

idPatient

fullName

biologicalMother

Birthdate

address

30001

Samyuktha

Catherine

2002-10-11

third cross mumbai

30002

Rosy

marry louise

2004-08-07

patel avenue mumbai

30003

Samskruthi

poonam

2000-11-01

saradhamma apartment mumbai

Inserting values into the doctor table

INSERT INTO doctor VALUES (1001, Dr.Robert, cardiologist, 2000);

INSERT INTO doctor VALUES (1002, Dr.Sagayaraj, Allergists/Immunologists, 2000);

INSERT INTO doctor VALUES (1003, Dr.Sreenath, Dermatologists, 1500);

idDr

fullName

Specialization

consulRates

1001

Dr.Robert

cardiologist

2000

1002

Dr.Sagayaraj

Allergists/Immunologists

2000

1003

Dr.Sreenath

Dermatologists

1500

Inserting values into the room table

INSERT INTO room VALUES (301, sharing ward, 1500);

INSERT INTO room VALUES (401, special ward, 2000);

INSERT INTO room VALUES (501, private room, 3000);

idRoom

roomName

cost

301

sharing ward

1500

401

special ward

2000

501

private room

3000

Inserting values into the inPatient table

INSERT INTO inPatient (idPatient, , outTime, idDr, idRoom)
VALUES (30001, 2020-04-11 11:20:00, 1001,301);

INSERT INTO inPatient (idPatient, , outTime, idDr, idRoom)
VALUES (30002, 2020-04-11 11:30:00, 1002,302);

INSERT INTO inPatient (idPatient, , outTime, idDr, idRoom)
VALUES (30003, 2020-04-11 11:50:00, 1003,303);

idPatient

entryTime

outTime

idDr

idRoom

30001

2020-04-11 11:00:00

2020-04-11 11:20:00

1001

301

30002

2020-04-11 11:22:00

2020-04-11 11:30:00

1002

302

30003

2020-04-11 11:32:00

2020-04-11 11:50:00

1003

303


Related Solutions

Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based on your entities defining The attributes within each table The primary and foreign keys within each table *****Show your database tables, tables attributes, primary and foreign keys***** Do not forget to check the lesson slides and videos that show you how to convert an ER/EER into a database schema, and how to create a database and tables using MS SQL Server.
Create a database with two tables as follows:- Students - StudentID, Name, Program FeePayment - StudentID,...
Create a database with two tables as follows:- Students - StudentID, Name, Program FeePayment - StudentID, Date, Description, Amount 1. Create a stored procedure that receives all the details of a student including fees and proceeds to insert insert the student details into the student details and the fee payment into the FeePayment table. All the operations should be done within a single transaction in a stored procedure. Note that the stored procedure works like a function that receives parameters....
Create the following SQL queries using the lyrics database below 1. List the first name, last...
Create the following SQL queries using the lyrics database below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in seconds 4....
Write create table statements to create tables for the Exoproduct employees computers database depicted by the...
Write create table statements to create tables for the Exoproduct employees computers database depicted by the relational schema created in a mini case MC5 in chapter 3. Use insert into statements to insert no fewer than 2 and no more than 10 records per table.
In MySQL, create a new schema titled <yourlastname>module3. Using the below file, create the tables in...
In MySQL, create a new schema titled <yourlastname>module3. Using the below file, create the tables in your new schema and populate with the supplied data. Tables do not have keys. Do not define them at this time. There are errors in the data population (INSERT) statements. It is your job to find the errors and correct them. This is important. You will need correct data for future exercises in this module. In the submission area, choose Write Submission and identify...
Create a Database from blank (scratch) for a manager and name it. Create and design a...
Create a Database from blank (scratch) for a manager and name it. Create and design a table and name it. For each fields click and choose proper a data type such as short text and name the field. Make at least three fields. Enter your records. Make sure to add your name as a record. Similarly create two more tables. By design tool, make a relationship between each of two tables at a time and drag a primary key one...
Create tables according to the mapping. Add 2 records to each. Create 5 queries for database...
Create tables according to the mapping. Add 2 records to each. Create 5 queries for database of 3 table joins to use most of the tables or group of tables in database. You should not have tables that are of no use. Student(ssn, name, major) Class(classID, name, f_ssn) Faculty(ssn, name, office_num, dept_id) Department(Dept_id, office_num, f_ssn) Enroll(s_ssn, classID, grade) Professor(f_ssn, alma-mater, tenured) Instructor(f_ssn, term_degree, type) Lecture(classID, method) Lab(classID, location) Person(ssn, dob, gender)
1.Create a Database in Access with the information The database must include: Database name: Monaco Enterprise  Mark...
1.Create a Database in Access with the information The database must include: Database name: Monaco Enterprise  Mark Johnson #87451 Table name: Contacts Delete the Primary key. Fields name and data type are (remember to choose the data type): Field Name Data Types Employee Name Short text Name Short text Last Name Short Text Work Yes/No 2.Go to the “Datasheet View” and enter the data. * Remember to save the table. 3.Move the last name field after the employee name. 4.The (data)...
Pivot Tables - Please explain how to acheive the following: Using the data below, create a...
Pivot Tables - Please explain how to acheive the following: Using the data below, create a Pivot Table that answers the question “Which salesperson sold the most in any particular month.” A manager wants to click on the Pivot Table and choose a month and have the name of that person appear with his or her amount for that month. Sales Data Salesperson May June July Aug. Sept. Oct. Albertson, Kathy $3,947.00 $557.00 $3,863.00 $1,117.00 $8,237.00 $8,690.00 Allenson, Carol $4,411.00...
using the lyrics database schema in mysql provided below. 1.)List the artist name of the artists...
using the lyrics database schema in mysql provided below. 1.)List the artist name of the artists who do not have a webaddress and their leadsource is “Directmail”? 2.)List the names of members in the artist called 'Today'. 3.)Report the total runtime in minutes FOR EACH album in the Titles table. 4.)List the firstname, lastname of members who are represented by the salesperson “Lisa Williams” 5.)List EACH salesperson’s firstname along with the number of Members that EACH SalesPerson represents. below is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT