1 / 27

Incremental Checking of OCL Constraints through SQL queries

Incremental Checking of OCL Constraints through SQL queries. Xavier Oriol and Ernest Teniente {xoriol,teniente}@essi.upc.edu. Motivation. IsSentTo. 1. receiver. {disjoint, complete}. Group. User. Message. Pair. ConversationGroup. phone: String state: String lastConnect : Date.

eden-best
Download Presentation

Incremental Checking of OCL Constraints through SQL queries

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Incremental Checking of OCL Constraints through SQL queries Xavier Oriol andErnest Teniente {xoriol,teniente}@essi.upc.edu

  2. Motivation IsSentTo 1 receiver {disjoint, complete} Group User Message Pair ConversationGroup phone: String state: String lastConnect: Date body: String creationT: Date creationT: Date * IsFormedBy 2 msg * Member 2..* * group user Sends 1 * Owner * 1 sender msg owned owner

  3. Motivation IsSentTo 1 receiver {disjoint, complete} ConversationGroup Pair Group User Message phone: String state: String lastConnect: Date body: String creationT: Date creationT: Date * IsFormedBy 2 msg * Member 2..* * group user Sends 1 * Owner * 1 sender msg owned owner contextUserinvMemberOfOwned: self.group->includesAll(self.owned)

  4. Motivation IsSentTo 1 receiver {disjoint, complete} Message Group User ConversationGroup Pair phone: String state: String lastConnect: Date body: String creationT: Date creationT: Date * IsFormedBy 2 msg * Member 2..* * group user Sends 1 * Owner * 1 sender msg owned owner contextUserinvMemberOfOwned: self.group->includesAll(self.owned) context Group invMessagesAfterCreation: self.msg->forAll(e| e.creationT > self.creationT)

  5. Motivation contextUserinvMemberOfOwned: self.group->includesAll(self.owned) context Group invMessagesAfterCreation: self.msg->forAll(e| e.creationT > self.creationT)

  6. Motivation How can wecheck OCL constraints? contextUserinvMemberOfOwned: self.group->includesAll(self.owned) context Group invMessagesAfterCreation: self.msg->forAll(e| e.creationT > self.creationT) Translating OCL constraints to SQL queries Idea: Query for theinstancesviolatingtheconstraint SELECT * FROM Group JOINIsSentToJOINMessage WHERE Group.createT>=Message.creationT

  7. Motivation There are some automatic OCL to SQL translators: • OCL2SQL fromOCLDresden • MySQL4OCL None of them is incremental

  8. Motivation IsSentTo 1 SELECT * FROM OwnerEXCEPTMember receiver {disjoint, complete} SELECT * FROM Group JOINIsSentToJOINMessage WHERE Group.createT<=Message.creationT ConversationGroup Message Pair User Group phone: String state: String lastConn: Date body: String creationT: Date creationT: Date * IsFormedBy 2 msg * 2..* Member * Hello! group user Sends 1 * Owner 1 * sender msg owned owner INSERT INTO Messages VALUES(‘Hello!’, ...) DATA Weneed to computethewholequeriesagain

  9. Our approach Goal Translate OCL constraintsinto incremental SQL queries

  10. Our approach Incremental Onlycheckthepotentiallyviolatedconstraints contextUserinvMemberOfOwned: self.group->includesAll(self.owned) context Group invMessagesAfterCreation: self.msg->forAll(e| e.creationT > self.creationT) Hello! New Message Onlycheck for thenewupdatedvalues Onlycheckwhetherthenewmessage “Hello!” has beencreatedafterthereceiver’sgroupcreation

  11. Our approach Ourapproach Translate OCL constraintsintoEDCs andEDCs to incremental SQL queries

  12. Our approach Translate OCL intoEDCs An EDC is a logicrulethat tells when a data update maycausetheviolation of someintegrityconstraint contextUserinvMemberOfOwned: self.group->includesAll(self.owned) ¬Owner(u, g) ∧ins_Owner(u, g) ∧ ¬Member(u, g) ∧ ¬ins_Member(u,g) → ⏊ ¬Owner(u, g) ∧ ins_Owner(u, g) ∧ Member(u, g) ∧ del_Member(u,g) → ⏊ Owner(u, g) ∧ ¬del_Owner(u, g) ∧ Member(u, g) ∧ del_Member(u,g) → ⏊

  13. Our approach TranslateEDCsinto SQL Idea: Jointhecolumns of thebound variables ins_Owner(u, g) ∧ ¬Owner(u, g) ∧ Member(u, g) ∧del_Member(u,g) → ⏊ SELECT * FROM ins_Owner ANTI JOINOwnerON (user,group) JOINMemberON (user,group) JOINdel_MemberON (user,group)

  14. Our approach TranslateEDCsinto SQL SELECT * FROM ins_Owner ANTI JOINOwnerON (user,group) JOINMemberON (user,group) JOINdel_MemberON (user,group)

  15. Our approach contextUserinvMemberOfOwned: self.group->includesAll(self.owned) TranslateEDCsinto SQL SELECT * FROM ins_Owner ANTI JOINOwnerON (user,group) JOINMemberON (user,group) JOINdel_MemberON (user,group) Hello! Thetranslationnever uses subqueries DBMS queryplanners can fullyoptimizethequery New Message Queryreturns empty set practically in constant time || ins_Owner || = 0

  16. Our approach context Group invMssgsAfterCreation: self.msg->forAll(e| e.cT > self.cT) TranslateEDCsinto SQL SELECT * FROM Group ANTI JOINdel_GroupON (group) JOINins_SendsToON (group) ANTI JOIN SendsTo ON (group) JOIN ins_Message ON (message) ANTI JOIN Message ON (message) WHERE Group.creationT>=ins_Message.creationT Hello! New Message Queryonlylooks for data joiningtheuniquenewmessage || ins_Message || = 1

  17. Our approach Someexperiments N = #Messages N/10 = #Users N/100 = #ins_Messages MemberOfOwned MsgsAfterCreation

  18. Our approach Someexperiments N = #Messages N/10 = #Users N/100 = #ins_Messages MemberOfOwned MsgsAfterCreation

  19. Our approach Someexperiments N = #Messages N/10 = #Users N/100 = #ins_Messages MemberOfOwned MsgsAfterCreation

  20. Our approach Someexperiments N = #Messages N/10 = #Users N/100 = #ins_Messages MemberOfOwned MsgsAfterCreation

  21. Our approach Someexperiments N = #Messages N/10 = #Users N/100 = #ins_Messages MemberOfOwned MsgsAfterCreation

  22. Our approach Someexperiments N = #Messages N/10 = #Users N/100 = #ins_Messages MemberOfOwned MsgsAfterCreation

  23. Our approach Someexperiments N = #Messages N/10 = #Users N/100 = #ins_Messages MemberOfOwned MsgsAfterCreation

  24. Our approach Someexperiments N = #Messages N/10 = #Users N/100 = #ins_Messages MemberOfOwned MsgsAfterCreation

  25. Conclusions Wetranslate OCL into incremental SQL Translatefrom OCL to EDCs TranslatefromEDCs to SQL Ourtranslation is incremental Whenanupdate is performed: Onlyconstraintsthatmight be violatedarechecked Only for the rellevant values FutureWork Enhancethesubset of OCL translatable to EDCs Usetriggers to avoid auxiliar tables

  26. Thank you Questions?

  27. Incremental Checking of OCL Constraints through SQL queries Xavier Oriol andErnest Teniente {xoriol,teniente}@essi.upc.edu

More Related