Looking “Behind” Some Languages - Describing with Help of UML (Many Simplifications) Jan Pettersen Nytun UiA.

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

Database Systems: Design, Implementation, and Management Tenth Edition
Extensible Markup Language XML MIS 520 – Database Theory Fall 2001 (Day) Lecture 14.
Introduction to XML This material is based heavily on the tutorial by the same name at
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
RDF (Resource Description Framework) Why?. XML XML is a metalanguage that allows users to define markup XML separates content and structure from formatting.
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
Component 4: Introduction to Information and Computer Science Unit 6: Databases and SQL Lecture 2 This material was developed by Oregon Health & Science.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
1 Credits Prepared by: Rajendra P. Srivastava Ernst & Young Professor University of Kansas Sponsored by: Ernst & Young, LLP (August 2005) XBRL Module Part.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
Component 4/Unit 6b Topic II Relational Databases Keys and relationships Data modeling Database acquisition Database Management System (DBMS) Database.
EEL 5937 Ontologies EEL 5937 Multi Agent Systems Lecture 5, Jan 23 th, 2003 Lotzi Bölöni.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
XML Extensible Markup Language
Data Models. 2 The Importance of Data Models Data models –Relatively simple representations, usually graphical, of complex real-world data structures.
Web Services: Principles & Technology Slide 3.1 Chapter 3 Brief Overview of XML COMP 4302/6302.
Defects of UML Yang Yichuan. For the Presentation Something you know Instead of lots of new stuff. Cases Instead of Concepts. Methodology instead of the.
XML Databases Presented By: Pardeep MT15042 Anurag Goel MT15006.
UML Class & Object Diagram II RELATIONS UML Class Diagram & Object Diagram II, Jan Pettersen Nytun, page no 1.
Jan Pettersen Nytun, UIA, page 1 Knowledge Representation Part IV The Semantics Web Starting with XML Jan Pettersen Nytun, UiA.
Chapter 3: Modeling Data in the Organization
COP Introduction to Database Structures
UML Class & Object Diagram I
Database Systems: Design, Implementation, and Management Tenth Edition
eXtensible Markup Language
XML: Extensible Markup Language
Knowledge Representation Part IV The Semantics Web Starting with XML
Lec7: SNMP Management Information
Unit 4 Representing Web Data: XML
Object Management Group Information Management Metamodel
Course Outcomes of Object Oriented Modeling Design (17630,C604)
SysML v2 Formalism: Requirements & Benefits
Entity-Relationship Model
XML QUESTIONS AND ANSWERS
Databases and Database Management Systems Chapter 9
XML: Extensible Markup Language
UML Class & Object Diagram II
CPSC-310 Database Systems
Eugenia Fernandez IUPUI
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
NOSQL databases and Big Data Storage Systems
XAML User Interface Creation in C#
9/22/2018.
Databases and Information Management
CS 174: Server-Side Web Programming February 12 Class Meeting
Chapter 7 Representing Web Data: XML
Introduction to Database Systems
Chapter 2 Database Environment.
Object Oriented Analysis and Design
MANAGING DATA RESOURCES
Database.
File Systems and Databases
Lec 3: Object-Oriented Data Modeling
Chapter 4 Entity Relationship (ER) Modeling
Chapter 20 Object-Oriented Analysis and Design
Object-Oriented Knowledge Representation
New Perspectives on XML
Databases and Information Management
Mapping UML to RDB, J.P.Nytun – page 1
Data Models in DBMS A model is a representation of reality, 'real world' objects and events, associations. Data Model can be defined as an integrated collection.
Some Data Models & Mapping to/from UML
Appendix A Object-Oriented Analysis and Design
Entity-Relationship Modelling
Legacy Databases.
Software Architecture & Design
New Perspectives on XML
Presentation transcript:

Looking “Behind” Some Languages - Describing with Help of UML (Many Simplifications) Jan Pettersen Nytun UiA

Outline UML XML Entity-Relationship (ER) model Relational Database Model

UML It is object-oriented by nature. Probably the most used modelling language for doing modelling of software. It is object-oriented by nature.

Object-Oriented Model Example 1 owns Person Car * name Model Model Instance :Car id1:Person :Car name=“Bob” The arrow is the instanceOf-relation

What is the model saying - if you should express it in English? 1 owns Person Car * name Model Model Instance :Car id1:Person A person have name and may own several cars. A car will always be own by one person. A person with name Bob (with id id1) owns two cars. The computer only knows that a there can be objects of class Person, which have names, etc.. We map it to description of “real people” be interpreting the names (but what if it is another languages then English, where Person means apple, etc. ?). :Car name=“Bob” Semantics: …the meaning of words and phrases…

Semantics - Our Example Human Perspective: A person have name and may own several cars. A car will always be own by one person. A person with name Bob (with id id1) owns two cars. We map it to description of “real people” by interpreting the names (but what if it is another languages then English, where Person means apple…?). Computer Perspective: The computer “knows” that a there can be objects of class Person, with slots storing text, etc..

A Model (like a statement) is about something, expressed with the building blocks of a language. Multiplicity (Role) Name Association Class 1 owns Property Person Car * name Object :Car id1:Person :Car name=“Bob” Slot Value Link

Some building blocks for defining class models (Using UML to Describe UML) Multiplicity Association (Role) Name Class 1 owns Person Car Association Property * name name 0..1 member- End 2 Class Property 1 name isAbstract * name isComposite multiplicity general owned- Attribute :Car id1:Person 1 Operation name parameters :Car name=“Bob” Model is only using things it describing itself - it is self describing (not minimal self describing?). owned- Operation This model describes how you may represent parts of the structure of class diagrams. It does not tell how a class diagram should look like.

What about a model for representing the objects shown on an object diagram? :Car id1:Person :Car name=“Bob” Slot Link Value

Building blocks for defining instance models (Using UML to Describe UML) 1 owns Person Car * name Owning- Instance Object id : String * Slot 1 link- Object 1 0..1 :Car id1:Person 1 instanceOf value Value Class * :Car name=“Bob” 1 Link String StringValue:String instanceOf Slot Link Object Association instanceOf 1 Value Where is the instanceOf found in object diagram? Property * owned- Attribute This model describes how you may represent the structure of an object diagram. It does not show how an object diagram should look like.

Outline UML XML Entity-Relationship (ER) model Relational Database Model

XML XML is a general format while html is meant for human readable web pages! XML has no fixed tag vocabulary – hence, users can define their own custom element and attribute names. It have some keywords, e.g. xmlns.

XML syntax Well-formed documents The document must have exactly one root element. The following is a well-formed XML document: <journal>This is a journal. </journal> The text enclosed by the root tags may contain an arbitrary number of XML elements. The basic syntax for one element is: <name attribute="value“…>content</name> start-tag content end-tag

XML syntax Continues… The root element can be preceded by an optional XML declaration. E.g., <?xml version="1.0" encoding="UTF-8"?> XML requires that elements be properly nested, i.e. no overlap. Well-formed example: Start-tag and end-tag of element medicalsystem Attribute <medicalsystem> <journal name=“Ola Norman" id=“1"> <journalrecord>May be a little overweight</journalrecord> </journal> <journal name=“Kari Norman" id=“2"> <journalrecord>Lack of iron.</journalrecord> <journalrecord>A slight attack of shopomania?</journalrecord> </journal> </medicalsystem>

xmlns - XML Namespace Gives unique names to elements and attributes. xmlns can be used to solve name conflicts inside one xml page, e.g., “table” may be a furniture or a data structure.

Namespace Examples An xml name space is often a web address. The address may go to a none existing web page - only the URI (URL) addressing mechanism is used. [1]: <root  xmlns:h=“http://www.w3.org/TR/html4/” xmlns:f="http://www.w3schools.com/furniture"> <h:table>    …. </h:table> <f:table>    <f:name>African Coffee Table</f:name>    <f:width>80</f:width>    <f:length>120</f:length> </f:table> </root> Xmlns is by definition bound to the namespace name http://www.w3.org/2000/xmlns/ which is an URI (URL)).

XML - UML Data Medical System UML Model <medicalsystem> :Journal :JournalRecord name=“Ola” SSN=“1” description=“May be a little bit fat?” * Journal JournalRecord 1 :Journal :JournalRecord name:String SSN:String description:String name=“Kari” SSN=“2” description=“Lack of iron.” :JournalRecord Data description=“A slight attack of shopomania?” <medicalsystem> <journal name=“Ola Norman" ssn=“1"> <journalrecord>May be a little bit fat?</journalrecord> </journal> <journal name=“Kari Norman" ssn=“2"> <journalrecord>Lack of iron.</journalrecord> <journalrecord>A slight attack of shopomania?</journalrecord> </journal> </medicalsystem>

What is meant with the following statement: “XML is Syntax” What is meant with the following statement: “XML is Syntax”? Syntax: …the rules about how words are arranged and connected to make phrases and sentences… XM does not have semantics like Java,… It is more like a way of structuring data, e.g., does not say anything about reasoning, execution, etc.

XML “is Syntax” The custom tags may indicate the meaning of the document's content, e.g., <musician>, and <record> - this can make XML documents at least partly self-describing (to humans). But what is meant by a tag, e.g., <musician>, is not given (the term “musician” is used but not explained).

From Wikipedia: XML is a generic framework for storing text or any data whose structure can be represented as a tree. Why a tree? <medicalsystem> <journal name=“Ola Norman" id=“1"> <journalrecord>May be a little overweight</journalrecord> </journal> <journal name=“Kari Norman" id=“2"> <journalrecord>Lack of iron.</journalrecord> <journalrecord>A slight attack of shopomania? </journalrecord> </journal> </medicalsystem> DirectedTree 0..1 Why tree? 0..1 topRoot 1 root Node child * edge

“May be a little overweight " “A slight attack of shopomania?" <medicalsystem> <journal name=“Ola Norman" id=“1"> <journalrecord>May be a little overweight</journalrecord> </journal> <journal name=“Kari Norman" id=“2"> <journalrecord>Lack of iron.</journalrecord> <journalrecord>A slight attack of shopomania? </journalrecord> </journal> </medicalsystem> medicalsystem journal journal name id journalrecord name id journalrecord journalrecord “Ola Norman" “1" Why tree? “Kari Norman" “2" “Lack of iron." “May be a little overweight " “A slight attack of shopomania?" Where did the start- and end-tags go? What about the order of things?

Building blocks for defining an XML document (Using UML) Element Attribute Text content Node * Building blocks for defining an XML document (Using UML) name : String Each XML document consists of nodes (in the model represented by Node class) and each node can contain either attributes (represented by Attribute class) or nested nodes. Both attribute and node have name (this and the Contains association are the reasons why there is a root abstract class named Element), in addition attribute has a value. Contains association expressing the fact that a node can contain both attributes and nodes is ordered on the elements end – this is because order of nodes is significant in XML. Text nodes are represented by a separate subclass of Node named TextNode. As each XML document consists of exactly one root node, it is convenient to define a separate subclass of Node class called RootNode for representing a root node in a document. This class also represents the document itself – it contains an additional attribute documentName. 0..1 Element Attribute container textContent : String value : String Is this an instance model? (A bit simplified)

An XML Schema functioning as model Example (simplified): <xsd:schema …. > <xsd:element name = “Building” type = “BuildingType”/> <xsd:complexType name=" BuildingType"> <xsd:attribute name=“name" type="xsd:string"/> <xsd:attribute name=“area" type="xsd:integer"/> </xsd:complexType> XML document (= instance of some XML schema)): <?xml version=1.0” …> … <Building name=“BlueBox" area = 300/> ….. Each XML document consists of nodes (in the model represented by Node class) and each node can contain either attributes (represented by Attribute class) or nested nodes. Both attribute and node have name (this and the Contains association are the reasons why there is a root abstract class named Element), in addition attribute has a value. Contains association expressing the fact that a node can contain both attributes and nodes is ordered on the elements end – this is because order of nodes is significant in XML. Text nodes are represented by a separate subclass of Node named TextNode. As each XML document consists of exactly one root node, it is convenient to define a separate subclass of Node class called RootNode for representing a root node in a document. This class also represents the document itself – it contains an additional attribute documentName.

Outline UML XML Entity-Relationship (ER) model Relational Database Model

Entity-Relationship (ER) model From Wikipedia: In software engineering, an entity–relationship model (ER model) is a data model for describing a database in an abstract way.  An object-relational database (ORD), is a database management system (DBMS) similar to a relational database, but with an object-oriented database model: objects, classes and inheritance are directly supported in database schemas and in the query language. …at the other extreme are OODBMSes in which the database is essentially a persistent object store for software written in anobject-oriented programming language, with a programming API for storing and retrieving objects, and little or no specific support for querying. A hierarchical database model is a data model in which the data is organized into a tree-like structure. The structure allows representing information using parent/child relationships: each parent can have many children, but each child has only one parent (also known as a 1-to-many relationship). All attributes of a specific record are listed under an entity type. In a database an entity type is the equivalent of a table. The network model is a database model conceived as a flexible way of representing objects and their relationships. Its distinguishing feature is that the schema, viewed as a graph in which object types are nodes and relationship types are arcs, is not restricted to being a hierarchy or lattice. While the hierarchical database model structures data as a tree of records, with each record having one parent record and many children, the network model allows each record to have multiple parent and child records, forming a generalized graph structure. Until the early 1980s the performance benefits of the low-level navigational interfaces offered by hierarchical and network databases were persuasive for many large-scale applications, but as hardware became faster, the extra productivity and flexibility of the relational model led to the gradual obsolescence of the network model in corporate enterprise usage.

Entity-Relationship model ER-metamodel (simplified abstract syntax): Role Relationsship 2..* minCardinality maxCardinality name * 1 Entity Attribute 1 name * minCardinality maxCardinality isDerived ER-model example (using ER concrete syntax): examination examinee Course Student name name

some specified visual notation for instances): examiner examination examinee Course Student 1 * name name Showing instances with some ad hoc notation (it does not seems like ER have some specified visual notation for instances): Course examination Student

Often an entity-relationship model is mapped to a Relational database model Student Student name StudentId name

Outline UML XML Entity-Relationship (ER) model Relational Database Model

Relational Database Model From Wikipedia: The most popular example of a database model is the relational model, which uses a table-based format. An object-relational database (ORD), is a database management system (DBMS) similar to a relational database, but with an object-oriented database model: objects, classes and inheritance are directly supported in database schemas and in the query language. …at the other extreme are OODBMSes in which the database is essentially a persistent object store for software written in anobject-oriented programming language, with a programming API for storing and retrieving objects, and little or no specific support for querying. A hierarchical database model is a data model in which the data is organized into a tree-like structure. The structure allows representing information using parent/child relationships: each parent can have many children, but each child has only one parent (also known as a 1-to-many relationship). All attributes of a specific record are listed under an entity type. In a database an entity type is the equivalent of a table. The network model is a database model conceived as a flexible way of representing objects and their relationships. Its distinguishing feature is that the schema, viewed as a graph in which object types are nodes and relationship types are arcs, is not restricted to being a hierarchy or lattice. While the hierarchical database model structures data as a tree of records, with each record having one parent record and many children, the network model allows each record to have multiple parent and child records, forming a generalized graph structure. Until the early 1980s the performance benefits of the low-level navigational interfaces offered by hierarchical and network databases were persuasive for many large-scale applications, but as hardware became faster, the extra productivity and flexibility of the relational model led to the gradual obsolescence of the network model in corporate enterprise usage.

Relational Database Model Table description Building BuildingId name area Table with values Building [2] BuildingId name area b1 BlueBox 300 Example of instance b7 Galleriet 300

Object-oriented UML Relational Mapping

Why This Mapping? Object technology and relational databases often used together. They are different: The relational paradigm is based on mathematical principles: Set theory. View on sets of “objects”. The object paradigm is somewhat different: Inheritance, behaviour, encapsulation,…view on “single object”. (However, the later version of SQL incooperats more if these things.)

Why This Mapping Continues... In the object paradigm objects are traversed by following links between objects. In the relational paradigm rows in different tables are connected with foreign keys (joining rows in different tables). (Mapping from UML class diagrams to tables and then back to class diagrams may lead to loss of information.)

UML to Relational Mapping: Class to Table Class diagram b is a derived attribute. C a : Integer c : Double /b : Integer NB! Not all classes are persistent. How to map this class?

UML to Relational Mapping: Class to Table Class diagram b is a derived attribute. C a : Integer c : Double /b : Integer NB! Not all classes are persistent. Table Table: C A: Integer C: Double

UML to Relational Mapping: one-to-one associations X Y x_pkey x_a1 y_pkey y_a1 1 Total participation Class diagram Object diagram X1 Y2 X2 Y3 X3 Y1 How to map this?

UML to Relational Mapping: one-to-one associations X Y x_pkey x_a1 y_pkey y_a1 1 Total participation Class diagram Object diagram X1 Y2 X2 Y3 X3 Y1 x_pkey Tables: Three different solutions x_a1 y_pkey y_a1 Table: XY Table: X and Y Table: Y and X

UML to Relational Mapping: one-to-many associations Object diagram X Y x_pkey x_a1 y_pkey y_a1 1 * Class diagram X1 Y2 X2 Y1 Y3 X3 Y4 X4 How to map this?

UML to Relational Mapping: one-to-many associations Object diagram X Y x_pkey x_a1 y_pkey y_a1 1 * Class diagram X1 Y2 X2 Y1 Y3 X3 Y4 X4 Tables: One possible solution y_pkey y_a1 x_pkey x_a1 Table: Y Table: X

UML to Relational Mapping: many-to-many associations Object diagram X1 Y2 Y3 X2 Y1 X4 Y4 X3 X Y x_pkey x_a1 y_pkey y_a1 * Class diagram How to map this?

UML to Relational Mapping: many-to-many associations Object diagram X1 Y2 Y3 X2 Y1 X4 Y4 X3 X Y x_pkey x_a1 y_pkey y_a1 * Class diagram Tables: One possible solution y_pkey y_a1 x_a1 Table: Y x_pkey Table: X Table: XY

References [1] http://www.w3schools.com/xml/xml_namespaces.asp [2] http://www.ibm.com/developerworks/rational/library/05/503_sebas/