56 C AbhishekTiwari DWM Experiment-2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Name: Abhishek Tiwari

Div: C

Roll No: 56

Moodle Id: 20102064

DWM
Experiment-2

Command:

-- create

CREATE TABLE Dim_Visitor (

Visit_Id int PRIMARY KEY,

Disease_Name varchar(20),

Treatment_Name varchar(20),

Start_Date date,

End_Date date

);

-- create

CREATE TABLE Dim_Doctor (

Doctor_Id int PRIMARY KEY,

Doctor_Name varchar(20),

Doctor_Qualification varchar(20),

Speciality varchar(10),

Experience int

);

-- create

CREATE TABLE Dim_Patient (

Patient_Id int PRIMARY KEY,

Patient_Name varchar(20),
Patient_Gender varchar(1),

Patient_Age int,

Patient_Address varchar(50),

Patient_Phone double,

Start_Date date,

End_Date date

);

-- create

CREATE TABLE Dim_Date (

Treatment_Date date PRIMARY KEY,

Date_Name varchar(20),

Year_Name varchar(30),

Quarter varchar(10),

Month varchar(10)

);

-- insert

INSERT INTO Dim_Visitor VALUES

(0001, 'A', 'A','2003-01-09','2003-01-31'),

(0002, 'C', 'B','2003-10-21','2003-11-30'),

(0003, 'A', 'A','2003-02-09','2003-03-31'),

(0004, 'C', 'B','2003-06-09','2003-07-31'),

(0005, 'C', 'B','2003-11-09','2003-11-30'),

(0006, 'E', 'R','2003-08-09','2003-08-31'),

(0007, 'G', 'H','2003-12-09','2003-12-31'),

(0008, 'H', 'J','2003-05-09','2003-05-31'),

(0009, 'A', 'J','2003-12-09','2003-12-31'),

(0010, 'I', 'K','2003-03-09','2003-03-31')

;
-- insert

INSERT INTO Dim_Doctor VALUES

(0001, 'A', 'A','V',10),

(0002, 'C', 'B','B',2),

(0003, 'A', 'A','S',21),

(0004, 'C', 'B','R',12),

(0005, 'C', 'B','T',5),

(0006, 'E', 'R','H',2),

(0007, 'G', 'H','K',8),

(0008, 'H', 'J','A',6),

(0009, 'A', 'J','L',9),

(0010, 'I', 'K','O',16)

-- insert

INSERT INTO Dim_Patient VALUES

(0001, 'A', 'F',21,'Vjhasdgfyuatgtfwerjhsdvba',5726437853,'2003-01-09','2003-01-


31'),

(0002, 'D', 'F',24,'Vjhasdgfyuatgtfwerjhsdvba',5726437853,'2003-10-21','2003-11-


30'),

(0003, 'V', 'M',29,'Vjhassdfguatgtfwerjhsdvba',5726437853,'2003-01-09','2003-01-


31'),

(0004, 'A', 'F',54,'Vjhasdgfyuatgtfwerjhsdvba',5726437853,'2003-01-09','2003-01-


31'),

(0005, 'H', 'M',19,'Vjhasdgfyuatgtfwerjhsdvba',5726437853,'2003-01-09','2003-


01-31'),

(0006, 'A', 'M',42,'Vjhasdgfyuatgtfwerjhsdvba',5726437853,'2003-01-09','2003-


01-31'),

(0007, 'O', 'M',54,'Vjhasdgfyuatgtfwerjhsdvba',5726437853,'2003-01-09','2003-


01-31'),

(0008, 'E', 'M',34,'Vjhasdgfyuatgtfwerjhsdvba',5726437853,'2003-01-09','2003-01-


31'),

(0009, 'P', 'F',65,'Vjhasdgfyuatgtfwerjhsdvba',5726437853,'2003-01-09','2003-01-


31'),

(0010, 'W', 'M',64,'Vjhasdgfyuatgtfwerjhsdvba',5726437853,'2003-01-09','2003-


01-31')
;

-- insert

INSERT INTO Dim_Date VALUES

('2003-01-21', 'Twenty First', 'Two thousand three','First','Jan'),

('2005-11-24', 'Twenty Four', 'Two thousand Five','Fourth','Nov'),

('2021-04-21', 'Twenty First', 'Two thousand twenty one','First','April'),

('2022-10-12', 'Twelve', 'Two thousand twenty two','Fourth','Octomber'),

('2006-06-11', 'Eleven', 'Two thousand six','Second','June'),

('2012-04-14', 'Fourteen', 'Two thousand twelve','First','April'),

('2018-07-12', 'Twelve', 'Two thousand eighteen','Second','July'),

('2010-04-01', 'One', 'Two thousand ten','First','April'),

('2012-01-21', 'Twenty First', 'Two thousand twelve','First','Jan'),

('2011-01-21', 'Twenty First', 'Two thousand eleven','First','Jan')

-- create

CREATE TABLE Fact_Medical (

Id int PRIMARY KEY,

Visit_Id int,

Doctor_Id int,

Patient_Id int,

Treatment_Date date,

Quantity int,

Cost int,

FOREIGN KEY (Visit_Id) REFERENCES Dim_Visitor(Visit_Id),

FOREIGN KEY (Doctor_Id) REFERENCES Dim_Doctor(Doctor_Id),

FOREIGN KEY (Patient_Id) REFERENCES Dim_Patient(Patient_Id),

FOREIGN KEY (Treatment_Date) REFERENCES Dim_Date(Treatment_Date)


);

-- insert

INSERT INTO Fact_Medical VALUES

(0001,0001 , 0001,0001,'2003-01-21',5,1200),

(0002,0002 , 0002,0002,'2005-11-24',1,0200),

(0003,0003 , 0003,0003,'2021-04-21',5,1600),

(0004,0004 , 0004,0004,'2022-10-12',8,3400),

(0005,0005 , 0005,0005,'2006-06-11',7,2700),

(0006,0006 , 0006,0006,'2012-04-14',5,1243),

(0007,0007 , 0007,0007,'2018-07-12',2,5345),

(0008,0008 , 0008,0008,'2010-04-01',5,0765),

(0009,0009 , 0009,0009,'2012-01-21',7,2452),

(0010,0010 , 0010,0010,'2011-01-21',7,9823);

-- fetch

SELECT CONCAT(Id, SPACE(9), Visit_Id, SPACE(9), Doctor_Id, SPACE(9), Patient_Id, SPACE(9),


Treatment_Date, SPACE(9), Quantity,SPACE(9), Cost) as Values_Inserted_In_FactTable FROM
Fact_Medical;

Output:

You might also like