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....
Use MYSQL to create the set of database tables of the relational database model and complete...
Use MYSQL to create the set of database tables of the relational database model and complete the associated queries given. Procedure: 1) Write all the SQL statements, necessary to create all tables and relationships, with Primary & Foreign keys. 2) Execute each statement in the correct order to create the relational database in MYSQL. 3)Insert some data into each table. 4) Use all your SQL create and Insert statements (from MS Word) to execute in the MYSQL WorkBench 5) Write...
Company X database Create an ER Diagram using UML notation for the following tables, then write...
Company X database Create an ER Diagram using UML notation for the following tables, then write out in the Relational model. Company X is a manufacturing company that binds and sells books. They have hired you to create database to track their Employees, Products, customers and their orders. All employees work with book Binding, Only some are designated as Reps for customers. Reps may have many customers. But each customer can only have 1 rep. They count to record each...
PartA: Create the database. Name the database doctorWho. Then create a page that allows Doctor Who’s...
PartA: Create the database. Name the database doctorWho. Then create a page that allows Doctor Who’s assistant to add a new patient record. You will need to give the assistant rights to this database. The assistant’s username is 'helper' and the password is 'feelBetter'. For this to work, you will need to create several pages so be sure to include all of them when submitting your work. Name the main page addPatient.php. PartB: Add at least five records to the...
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT