course: Database Systems (NDBI025) SS2017/18
doc. RNDr. Tomáš Skopal, Ph.D. Mgr. Martin Nečaský, Ph.D. RNDr. Michal Kopecký, Ph.D.
Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague
introduction to logical database models . object, (object-)relational model . other (XML, RDF)
(object-)relational model in detail . introduction . UML schema conversion
T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 2 abstraction conceptual layer . models a part of the “structured” real world relevant for applications built on top of your database ▪ real world part = real-world entities and relationships between them . different conceptual models (e.g. ER, UML) logical layer . specifies how conceptual components are represented in logical machine interpretable data structures . different logical models (e.g. object, relational, object-relational, XML, graph, etc.) physical model . specifies how logical database structures are implemented in a specific technical environment implementation . data files, index structures (e.g. B+ trees), etc.
T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 3 specifies how conceptual entities are represented in data structures used by your system for various purposes, e.g., . for data storage and access ▪ graph of objects ▪ tables in (object-)relational database ▪ XML schemas in native XML database . for data exchange ▪ XML schemas for system-to-system data exchange . for data publication on the Web ▪ XML schemas for data publication ▪ RDF schemas/OWL ontologies for publication on the Web of Linked Data in a machine-readable form . other
T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 4 different logical models for data representation . for data storage and access ▪ object model ▪ relational model (or object-relational model) ▪ XML model . for data exchange ▪ XML model . for data publication on the Web ▪ XML model ▪ RDF model . other modern software systems have to cope with many of these different logical models
T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 5 problem 1: Designers need to choose the right logical model with respect to the nature of the prospective access to data.
or
problem 2: Designers need to design several logical schemas for different models applied in the system. . logical schemas can be derived automatically or semi- automatically from a single conceptual schema Model-Driven Development
T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 6 problem 1: Conceptual Schema ?
Relational model XML model Object model
T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 7 problem 2: Conceptual Schema
Relational schema XML schema Ontology
T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 8 an approach to software development theoretically, it enables to create executable schemas instead of executable code (= classical approach) . more precisely, schemas are automatically converted to executable code . recent idea, not applicable for software development in practice today ▪ lack of tool support BUT, we will show you how it can be profitably applied for designing logical data schemas . allows to deal with different logical models which we need to apply in our system
T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 9 considers UML as a general modeling language distinguishes several levels of abstraction of logical data schemas . Platform-Independent Level conceptual ▪ hides particular platform-specific details layer
. in terms of database Platform-Specific Level modeling taxonomy ▪ mapping of the conceptual schema (or its part) to a given logical model ▪ adds platform-specific details to the conceptual schema logical . Code Level layer ▪ schema expression in a selected machine-interpretable logical language ▪ for us, e.g., SQL, XML Schema, OWL
T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 10 Information System for Public Procurement . http://www.isvzus.cz (in Czech only ) . current project of Czech eGov . aims at increasing transparency in Public Procurement in Czech Rep. system has to deal with many logical models: . relational data model for data storage . XML data model for exchanging data with information systems of public authorities who issue public contracts . RDF data model for publishing data on the Web of Linked Data in a machine-readable form ▪ this is not happening in these days (March 2012) but we, Charles University, OpenData.cz, are working hard to show how to do it
T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 11 class P...
+tenderingSupplier Organization Address 0..* 0..1 1 - legalName - streetName +awardedSupplier - officialNumber - streetNumber - city 0..1 Tender +contractingAuthority 1 - country
- estimatedEndDate +mainAddress 1 0..1 - offeredPrice +tenderAddress
+issuedContract 0..* +tenderedContract +suppliedContract Contract 0..* 0..* - referenceNumber - title - description 0..1 ItemType - mainObject - additionalObject [0..*] - code 0..* 0..* 0..1 - title - startDate - endDate - estimatedPrice +lot 0..* - agreedPrice - actualPrice - numberOfTenders +parentContract 1 ...also logical object schema?
T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 12 class PSM_RELATIONAL
Organization +FK_Organization_Address
«column» 0..* * legalName: VARCHAR2(50) * officialNumber: NUMBER(9) +PK_Organization (addressId = addressId) *PK organizationId: NUMBER(8) +PK_Organization «FK» «FK» 1 *FK addressId: NUMBER(8) 1 (tenderingSupplierId = organizationId) «FK» +PK_Address 1 + FK_Organization_Address(NUMBER) Address «PK» +FK_Tender_Organization 0..* + PK_Organization(NUMBER) «column» «unique» streetName: VARCHAR2(50) Tender + UQ_Organization_officialNumbe(NUMBER) (awardedSupplierId = organizationId) streetNumber: VARCHAR2(50) «FK» city: VARCHAR2(50) «column» +PK_Organization 1 country: VARCHAR2(50) * estimatedEndDate: DATE *PK addressId: NUMBER(8) * offeredPrice: NUMBER(9) (awardedSupplierId = organizationId) «FK» *PK tenderId: NUMBER(8) +FK_Contract_Organization 0..* *FK tenderingSupplierId: NUMBER(8) «PK» +FK_Contract_Organization + PK_Address(NUMBER) *FK tenderedContractId: NUMBER(8) Contract 1 +PK_Address 1 +PK_Address «FK» «column» 0..* ItemType + FK_Tender_Contract(NUMBER) * referenceNumber: NUMBER(8) (tenderAddressId = addressId) + FK_Tender_Organization(NUMBER) * title: VARCHAR2(50) «column» description: CLOB «FK» «PK» (tenderAddressId = addressId) *PK code: NUMBER(8) * startDate: DATE + PK_Tender(NUMBER) «FK» * title: VARCHAR2(50) * endDate: DATE +FK_Contract_Address +FK_Tender_Contract 0..* * estimatedPrice: NUMBER(9) «PK» agreedPrice: NUMBER(9) 0..* + PK_ItemType(NUMBER) actualPrice: NUMBER(9) +FK_Contract_Address numberOfTenders: NUMBER(2) +PK_Contract +PK_ItemType 1 *PK contractId: NUMBER(8) 0..* «FK» 1 *FK contractingAuthorityId: NUMBER(8) (contractId = code) (tenderedContractId = contractId) FK awardedSupplierId: NUMBER(8) «FK» *FK mainAddressId: NUMBER(8) FK tenderAddressId: NUMBER(8) +PK_Contract 0..* +FK_Item_ItemType FK parentContractId: NUMBER(8) 1 Item «FK» + FK_Contract_Address(NUMBER) «column» + FK_Contract_Address(NUMBER) (parentContractId = contractId) * code: NUMBER(8) +PK_Contract +FK_Item_Contract + FK_Contract_Contract(NUMBER) «FK» FK contractId: NUMBER(8) + FK_Contract_Organization(NUMBER) ...UML, but not 0..* «FK» 1 + FK_Contract_Organization(NUMBER) (contractId = contractId) «FK» «PK» +FK_Contract_Contract + FK_Item_Contract(NUMBER) conceptual + PK_Contract(NUMBER) + FK_Item_ItemType(NUMBER) 0..* «unique» + UQ_Contract_referenceNumber() schema! T. Skopal. M. Nečaský Logical database models, relational model (NDBI025, Lect. 2) 13 notes to previous UML diagram . it is UML class diagram . but enhanced with features for modeling schema in (object-)relational model . enhancement = stereotypes
stereotype = UML construct assigned to a basic construct (class, attribute, association) with a specific semantics, e.g., . <