Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction Simplified EER Diagram Rational Schema Relational Design (Access implementation) Normalization Query and SQL implementation Agenda.

Similar presentations


Presentation on theme: "Introduction Simplified EER Diagram Rational Schema Relational Design (Access implementation) Normalization Query and SQL implementation Agenda."— Presentation transcript:

1

2 Introduction Simplified EER Diagram Rational Schema Relational Design (Access implementation) Normalization Query and SQL implementation Agenda

3 Introduction Premier Elder Care strives to provide high quality, reliable and affordable care to seniors, persons recovering from surgery, or those who are physically challenged in the comfort of their own homes with the highest possible level of independent living. IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

4 Simplified EER Diagram IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

5 Relational Design Schema 1 Person (SSN, DOB, Gender, Email, Fname, Lname, MI, Str.Add, City, Phone,Age a) Client(SSN, …, Account_Number.11) b) Patient(SSN, …, PID, Condition, Service_Needed, Allergic_Reaction, IC_Name.4, EMCID.14a, SSN/PID.1a, Mname.2) c) Employee(SSN, …, Type, Title, Hourly_Rate, Salary, Term_Contract, Start_Date, IC_Name.4, Mname.2) d) Dependent(SSN, …, ) e) Prospective_Client(SSN, …, Condition, EID.3 ) 2 Medication(Mname, Type, Components, Condition) 3 Event&Workshop(EID, Duration, Frequency_Per_Month, Cost, Location, Type, SchID.8, LID.12, At_Emp1) 4 Insurance_Company(IC_Name, Type, Address, Phone, Insurance_Programs 5 Payments(Pay_ID, Payment_Type, Date, Amount, Payed_By, Payed_To, IC_Name.4, Employee.1c, OID.13, EID.3 6 Service(SID, Duration, Difficulty_Level, Type, Date, Location, Performing_Employee, a) Daily Activity(SID, …, Performing_Employee, Used_Medicine b) Instrumental Activity(SID, …, Performing_Employee, Cost, Requirements 7 Contract(CID, Duration, Amount, SSN/PID.1b, S.Time.8, S.Days.8, SSN/PID.1c, SSN/PID.1a, Account_Number.11, LID.12 8 Schedule(S.Time, S.Days, Available_Employees, Patients_Needed 9 Inventory_Items(IID, OID.13, Product_Name, Type, Dimensions, Weight, Material, Supplied_by, Checked-in_by, 10 Supplier&Contractor(Supp_ID, Service_Name, Address, Phone, Items 11 Account(Account_Number, Owner, Bank) 12 Location(LID, Address, Place_Name, Cost, Open_Time ) IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

6 Relational Design Schema ( continued) 13 Orders(OID, Items, Quantity, Cost, Ordered_By, Supp_ID.10) 14 Emergency_Contact (EMCID, Phone 14a. Primary_Doctor(EMCID, Phone, License_Num, Specialty, Hospital_Name 15 14b. Others(EMCID, Phone, Relationship 16 Has(SSN/PID.1c, SSN/PID.1d ) 17 Provides(SSN/PID.1c, SID.6 ) 18 Takes(SSN/PID.1b, M.Name.2 ) 19 Gives_Feedback(SSN/PID.1c, SSN/PID.1b, NoteByEmployee, NoteByPatient 20 Receives(SID.6, SSN/PID.1b ) 21 Consists(SID.6, CID.7 ) 22 Contacts(SSN/PID.1b, EMCID.14 ) 23 Invited_To(SSN/PID.1, EID.3 ) 24 Related_To(SSN/PID.1b, EMCID.14b ) 25 Acquired_Through(EID.3, SSN/PID.1e ) IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

7 Access implementation of relational design IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

8 Normalization Functional dependencies: 1.Patient (SSN, DOB, Gender, Email, Fname, Lname, MI, Str.Add, City, Phone, Age, PID, Condition, Service_Needed, Allergic_Reaction, IC_Name.4,, SSN/PID.1a, Mname.2) SSN  Condition SSN  Service_Needed SSN  Allergic_Reaction SSN  EMCIDDOB  Age IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

9 1NF : Condition (SSN, ConditionID, Condition) Service_Needed (SSN, ServiceID, Service_Needed ) Allegic_Reaction(SSN, AllergicID, Allergic_Reaction) EMCID (SSN, EMCID) 3NF : Birthday (DOB, Age) Patient (SSN, DOB, Gender, Email, Fname, Lname, MI, Str.Add, City, Phone, PID, IC_Name.4, SSN/PID.1a, Mname.2) This is also in BCNF IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

10 1NF : Type_details (IID, TypeID, description) 2NF: Order details (OID, Supplied_by, Checked_in_by) 3NF Item_info(Product_Name, descripton) Inventory_Items(IID, Product_Name, Dimensions, Weight, Material) This is also in BCNF 8. Inventory_Items(IID, OID.13, Product_Name, Type, Dimensions, Weight, Material, Supplied_by, Checked-in_by, descripton) Functional dependencies: IID  Type OID  Supplied_by, Checked_in_by Product_Name  description IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL Normalization ( 2 )

11 Query 1: Demand Corrections Each year, the care center will predict some expectations of demand for different kinds of service and manage the employees into different services in order to improve the human capital’s efficiency. For example, the company expects that they are going to provide fifty service A, forty three service B and sixty seven service C. While the actual number they provide is fifty eight service A, thirty three service B and seventy service C. Thus, we can use the chi-square test to say whether the company needs to make some adjustments on its predication demands for different services. In this way, the company can decide whether to hire more employee for different services. Chi-square equation: IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

12 Q1:Demand Corrections SQL [Query: Observed_Value] SELECT sid, count(sid) AS observed_service FROM daily_activity WHERE date like '**/**/2013' GROUP BY sid; [Query: Expected_Value] SELECT Daily_Activity.sid, Count(Daily_Activity.sid) AS total, (total/3) AS expected_value FROM Daily_Activity WHERE Daily_Activity.date Like '**/**/2013' OR '**/**/2012' OR '**/**/2011' GROUP BY Daily_Activity.sid; SELECT sum((o.observed_service-e.expected_value)^2)/sum(e.expected_value) AS chisquare, iif (chisquare<3.84, "Do not need to adjust the demand", "Should adjust the demand") AS conclusion FROM daily_activity AS d, observed_value AS o, expected_value AS e WHERE o.sid=e.sid; IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

13 IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL Q1:Demand Corrections Outcome

14 Query 2: Feedback ranking The business justification for the query, how it will benefit their organization Allows the management staff to access the service performance of each employee base on the quality index in selected date range. The model you are using, give the mathematical formula explain variables, and provide a reference. The quality index is evaluated base on the total service hour an employee has completed and the total score each employee receives for each of the service in a certain date range. It can be evaluated as where represents the score received at each service and represents the hours provided at each service. IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

15 Q2:Feedback ranking SQL & outcome SELECT S.SSN_Employee, ROUND((SUM(G.Rate_Score)/SUM(S.Duration_hrs)), 3) AS quality_index FROM Service AS S, Gives_Feedback AS G WHERE (((S.Date) Between [Start Date] And [End Date])) GROUP BY S.SSN_Employee ORDER BY quality_index DESC; IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

16 Objective: To calculate the optimum number of a medicine to order to minimize inventory holding and ordering costs. Justification: With this query, the user can see the amount of a medicine to order, the ordering cycle and when to place an order given the potential delays. Q* RLRL T t Q R L : Reorder Level Q*: Optimum Quantity T: Ordering Cycle Query 3: Economical order quantity IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

17 SELECT m. MID, Round(SQRT((2 * m.Demand * (o.OrderingCost+ o.ShippingCost+e.HourlyRate)/i.HoldingCost) AS QUANTITY_TO_ORDER, Round(m.demand/ QUATITY_TO_ORDER) AS ORDERING_CYCLE, (m.DailyUsageRate * o.LeadTime) AS REORDER_LEVEL, i. RemainingQuantity ((m.price* m.demand) + ((o.OrderingCost+ o.ShippingCost+ e.HourlyRate)/ ORDERING_CYCLE) + i.holdingCost*QUATITY_TO_ORDER/2), AS TOTAL_COST FROM MEDICATION as m, INVENTORY_ITEM as i, EMPLOYEE as e, ORDER as o WHERE m.MID = I. IID_OID AND e.SSN=o.CSSN AND i.IID_OID=o.OID GROUP BY m.MID; Q3:EOQ SQL & outcome IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

18 Purpose Among these patients whom were introduced to the company through events and workshops to the company, find the correlation between their medical expenses with the firm and the severity of their conditions, i.e. what would be the estimated spending of a patient if we know his/her condition is at this level. (Assuming we are quantifying patients' condition from 1 to 10.) Mathematical Model Query 4: Medical cost expectation n= # of patients = count(p.SSN) a = condition = p.Condition sum(a)= sum(p.Condition) b = a.Spending sum(b) = sum(a.Spending) sum(ab) = sum(p.Condition*a.Spending) IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

19 Q4:Cost expectation SQL & outcome SELECT (Count(p.ssn) * Sum(p.condition * a.spending) - Sum(p.condition) *Sum(a.spending) ) / ( Count(p.ssn) * Sum(p.condition^2) - Sum(p.condition)^2 ) AS coefficient, 1 / Count(p.ssn) * ( Sum(a.spending) - coefficient * Sum(p.condition) ) AS intercept FROM patient p, client c, account a, event e WHERE p.ssn = c.ssn_patient AND a.patient_id = p.ssn AND c.ssn_client = a.clientid AND p.ssn IN (SELECT DISTINCT pc.ssn FROM prospective_client pc) Sample Outcome Enter the level of the patient’s condition, and the query will yield output of estimated cost for this patient. IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

20 Q4:Cost expectation outcome IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

21 Query5: Optimized Employee Allocation Business Justification: This query will allow the allocation of employees to serve the needs of customers while minimizing the distance traveled from employees to patients’ residences. Then, using an integer program employees are allocated to patients by minimizing the total distance traveled of the system. The benefits include savings in transportation time and a reduction in emergency response time to patients. Mathematical Model: Initially, through use of a query every combination of patient and employee are retrieved. Each pair is labeled: Where Y represents the allocation of employee j to patient i. These will be represent the decision variables in a Linear Program (LP). The travel times between candidate employees and the prospective patient are then determined from Google Maps. These values are used to fill a distance matrix, d. Where d is the distance from candidate employee residence j to patient i residence. This results in the equation to be minimized, Z. IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

22 Q5: Optimized Employee Allocation outcome Core SQL Code: SELECT P.ID,P.ZID,E.ID,E.ZID FROM Employee.E,Patient.P Sample Output: From the Employee and Patient Tables, every combination of P.ID, E.ID, P.ZID and E.ZID are extracted. IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

23 Distance Matrix Created on MATLAB calculating distances on Google Maps. Zip Code ID’s Assigned Instead zip code to facilitate matrix indexing in MATLAB Distance Matrix: Q5: Optimized Employee Allocation outcome IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

24 Employees are allocated using Binary Integer Programming (BIP) on MATLAB y=[x zeros(length(x),1)]; for i=1:length(y) y(i,end)=d(y(i,2),y(i,4)); end A=[ones(1,5) zeros(1,25); zeros(1,5) ones(1,5) zeros(1,20); zeros(1,10) ones(1,5) zeros(1,15); zeros(1,15) ones(1,5) zeros(1,10); zeros(1,20) ones(1,5) zeros(1,5); zeros(1,25) ones(1,5)]; b=ones(6,1); f=y(:,end)' [s,fval]=bintprog(f,[],[],A,b,zeros(1,30),[]) Q5: Optimized Employee Allocation outcome IntroductionEER DiagramSchemaTablesNormalizationQuery & SQL

25


Download ppt "Introduction Simplified EER Diagram Rational Schema Relational Design (Access implementation) Normalization Query and SQL implementation Agenda."

Similar presentations


Ads by Google