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

OLAP Hospital DATA BASE

The document outlines SQL commands to drop existing tables and create new ones for a healthcare database. It includes tables for dates, patients, doctors, payment methods, and appointments, with specified primary keys and foreign key relationships. The structure is designed to manage appointment data, linking patients to doctors and payment methods through a fact table.

Uploaded by

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

OLAP Hospital DATA BASE

The document outlines SQL commands to drop existing tables and create new ones for a healthcare database. It includes tables for dates, patients, doctors, payment methods, and appointments, with specified primary keys and foreign key relationships. The structure is designed to manage appointment data, linking patients to doctors and payment methods through a fact table.

Uploaded by

charlie.cocha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

DROP TABLE IF EXISTS Fact_Appointments;

DROP TABLE IF EXISTS D_Date;

DROP TABLE IF EXISTS D_Patient;

DROP TABLE IF EXISTS D_Doctor;

DROP TABLE IF EXISTS D_Payment_Method;

CREATE TABLE D_Date (

date_id INT PRIMARY KEY, -- Format: YYYYMMDD

day TINYINT,

week TINYINT,

month TINYINT,

quarter TINYINT,

year SMALLINT

);

CREATE TABLE D_Patient (

patient_id INT PRIMARY KEY,

name VARCHAR(100),

gender VARCHAR(10),

dob DATE

);

CREATE TABLE D_Doctor (

doctor_id INT PRIMARY KEY,

name VARCHAR(100),

specialization VARCHAR(100)

);

CREATE TABLE D_Payment_Method (

payment_method_id INT PRIMARY KEY AUTO_INCREMENT,

method VARCHAR(30) UNIQUE

);
CREATE TABLE Fact_Appointments (

appointment_id INT PRIMARY KEY,

patient_id INT,

doctor_id INT,

appointment_date_id INT,

revenue DECIMAL(10,2),

payment_method_id INT,

FOREIGN KEY (patient_id) REFERENCES D_Patient(patient_id),

FOREIGN KEY (doctor_id) REFERENCES D_Doctor(doctor_id),

FOREIGN KEY (appointment_date_id) REFERENCES D_Date(date_id),

FOREIGN KEY (payment_method_id) REFERENCES D_Payment_Method(payment_method_id)

);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy