Answer a) some of the attributes is not clear in the image so i have not included in table column.
CREATE TABLE Patient (
PatientID int ,
PayerId int,
FirstName varchar(255),
LastName varchar(255),
Gender varchar(255),
Phonenumber varchar(255),
PRIMARY KEY (PatientID),
FOREIGN KEY (PayerId) REFERENCES Payer(PayerId)
);
--------------------------------------------------------------
CREATE TABLE Payer (
PayerId int,
PayerCode varchar(255),
PayerName varchar(255),
PRIMARY KEY (PayerId)
);
----------------------------------------------------------
CREATE TABLE PatientAddress (
PatientID int ,
PatientAddress varchar(255),
City varchar(255),
State varchar(255),
zipcode int,
AssignmentNumber int,
FOREIGN KEY (PatientID ) REFERENCES Patient(PatientID)
);
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------
CREATE TABLE Provider (
ProviderID int ,
DeptId int,
Provider_FirstName varchar(255),
Provider_LastName varchar(255),
DOB date,
salary double,
PRIMARY KEY (ProviderID),
FOREIGN KEY (DeptId) REFERENCES Department(DeptId )
);
-------------------------------------------------------------
CREATE TABLE Department(
DeptId int,
Discription varchar(255),
specialization varchar(255),
PRIMARY KEY (DeptId)
);
--------------------------------------------------------------------------
CREATE TABLE ProviderAddress (
ProviderID int,
ProviderStreet varchar(255),
City varchar(255),
State varchar(255),
zipcode int,
FOREIGN KEY (ProviderID) REFERENCES Provider(ProviderID)
);
-----------------------------------------------------------------------------
CREATE TABLE ProviderSchedule (
ProviderID int NOT NULL,
startDate date,
startime time,
endtime time,
FOREIGN KEY (ProviderID) REFERENCES Provider(ProviderID)
);
---------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------
CREATE TABLE diagnosisGroup(
diagnosisID int,
Discription varchar(255),
diagnosisName varchar(255),
PRIMARY KEY (diagnosisID)
);
----------------------------------------------------------------------------
CREATE TABLE diagnosisList(
diagnosisID int,
diagnosisListID int,
diagnosisListName varchar(255),
diagnosisPrice int,
PRIMARY KEY (diagnosisListID ),
FOREIGN KEY (diagnosisID ) REFERENCES diagnosisGroup(diagnosisID
)
);
--------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------
TASK PROCESS TABLE
CREATE TABLE TASKProcess(
TASKProcessID int,
diagnosisID int,
PatientID int,
diagnosisListID int,
DateOFProcess DATE,
PRIMARY KEY (TASKProcessID ),
FOREIGN KEY (diagnosisID ) REFERENCES diagnosisGroup(diagnosisID
),
FOREIGN KEY (PatientID) REFERENCES Patient(PatientID ),
FOREIGN KEY (diagnosisListID ) REFERENCES
diagnosisList(diagnosisListID)
);
*************************************************************************************************************************************
Answer b)
******************************************************************************************************************************************
Answer c)
Below is basic query
SELECT * FROM patientaddress
WHERE city IN ('basti');
query using like keyword
SELECT * FROM patient
WHERE FirstName LIKE 'a%';
inner join query
SELECT Patient.FirstName,Patient.PatientID,Payer.Name
FROM patient,payer
INNER JOIN ON patient.patientID= payer.PatientID;
groupBy clause
SELECT count(*)
FROM patientaddress
WHERE patient id <500
GROUP BY city;
***********************************************************************************************************************
Answer d) create view example
In SQL, a view is a virtual table based on the result-set of an SQL statement.
A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.
CREATE VIEW PatientDetail
SELECT FirstName, LastName,PatientID
FROM Patient
WHERE PatientID= 100;
Now the PatientDetail will be view table
SELECT * FROM PatientDetail ;
*********************************************************************************************************************************************
Hospital Patient Reglstration System Hospltal Patient Registration System Part 2: Relational Sche...
The following tables form part of a database held in a relational DBMS: Hotel (hotelNo, hotelName, city) Room (roomNo, hotelNo, type, price) Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo) Guest (guestNo, guestName, guestAddress) where Hotel contains hotel details and hotelNo is the primary key; Room contains room details for each hotel and (roomNo, hoteINo) forms the primary key; Booking contains details of bookings and (hoteINo, guestNo, dateFrom) forms the primary key; Guest contains guest details and guestNo is the primary key....
Prepare and execute each of the queries listed using the "Adventureworks2012" database in SQL: Server: http://msftdbprodsamples.codeplex.com/releases/view/93587 When all of your queries are complete, cut and paste the SQL Syntax into a word document. In order to see what the column names are, you need to click on the table and then Columns to see the field names. Make sure to include column headings that make sense in the queries (use the as “Field Name” after the field selected). Multi-table Queries...
The relational schema for the Academics database is as follows DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) FIELD(fieldnum, id, title) INTEREST(fieldnum* acnumk, descrip) Some notes on the Academics database An academic department belongs to one institution (instname) and often has many academics. An academic only works for one department. Research papers (PAPER) are often authored by several academics, and of course an academic often writes several papers (AUTHOR) A research field (FIELD) often...
The relational schema for the Academics database is as follows DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) FIELD(fieldnum, id, title) INTEREST(fieldnum* acnumk, descrip) Some notes on the Academics database An academic department belongs to one institution (instname) and often has many academics. An academic only works for one department. Research papers (PAPER) are often authored by several academics, and of course an academic often writes several papers (AUTHOR) A research field (FIELD) often...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*, acnum*) FIELD(fieldnum, id, title) INTEREST(fieldnum*, acnum*, descrip) Some notes on the Academics database: ● An academic department belongs to one institution (instname) and often has many academics. An academic only works for one department. ● Research papers (PAPER) are often authored by several academics, and of course an academic often writes several papers (AUTHOR). ●...
Exercise 3 [12.5 marks] Given the Restaurant management system database that contains the following tables (primary keys are underlined and foreign keys are preceded with #): Customer (customerID,customerFirstName,customerLastName,customerAddress) Oreder (orderID,orderDate, #customerID,#menuItemID,#staffID) MenuItem(menuItemID, menuItemName,ingredients,type,availability) Staff(staffID, staffName, staffPhoneNumber, staffRole ) OrderPayment(paymentID,paymentAmount,#orderID,#staffID) 1) Without using DISTINCT, write the SQL query equivalent to the following one:[1.5 marks] SELECT DISTINCT menuItemName FROM MenuItem WHERE type = ‘Vegetarian’ OR availability= ‘Yes’; 2) Express the following queries in SQL: a) Find the number of orders placed by...
Tables: Create table Item( ItemId char(5) constraint itmid_unique primary key, Decription varchar2(30), Unitcost number(7,2)); Create table Customer( custID char(5) constraint cid.unique primary key, custName varchar2(20), address varchar2(50)); Create table Orderdata( orderID char(5) constraint oid_uniq primary key, orderdate date, shipdate date, ItemId char(5) references Item.ItemId, No_of_items number(4), Unitcost number(7,2), Order_total number(7,2), custID char(5) references customer.custID); Insert Into Item values(‘A123’,’Pencil’,2.5); Insert Into Item values(‘B123’,’Pen’,15); Insert Into...
Topic: Inventory Manangement Part A. Database Creation Your database should have a minimum of 4 tables and include both one-to-many and many-to-many relationships. Be sure to include some numeric and/or date fields. Define all appropriate constraints, using the proper naming conventions (see Structure Notes below). Populate your database with at least 30 records in the main table(s), and whatever is needed in related tables. Submit the following: • a short description of the purpose of the database and what the...
Please help me to solve Please, No handwriting COURSE; introduction to database Q- write a query SQL by Using the info below A. Normalize the Tables (in 3NF at least) B. Create the Normalized Tables and Populate them with at least 5 Rows C. Write the Wholesale Management System requested Queries & Execute them VERY IMPORTANT Screenshots from MySQL (or any other software you use) of all the tables after queries result. - Database system for a Wholesale Management System...
Deliverable 1. Simple SQL Statements Caution: Read the instructions carefully! Each question is based on a single SQL statement, and the single SQL statement might contain sub-queries (additional SELECT statements) within the statement. Provide a list all of the Customer ID, Customer Names, and States and sort the list in alphabetical order by Customer Name. Provide a list of all of the Customer ID, Customer Names, and States, and sort the list by state with the Customer Names in alphabetical...