3. Data Models for Engineering Data
Total Page:16
File Type:pdf, Size:1020Kb
3. Data Models for Engineering Data Conventional and Specific Ways to Describe Engineering Data Overview • Conventional Models – Overview of Data Models – Logical Models • Databases and the Relational Data Model • Object-oriented Data Models • Semi-structured Data Models – Conceptual Models • The Entity Relationship Model (ER) • The Unified Modeling Language (UML) • Engineering Data Models – The Standard for the Exchange of Product Model Data (STEP) • STEP EXPRESS as a modeling language • EXPRESS-G as a graphical/conceptual model – STEP files Schallehn: Data Management for Engineering Applications Reminder: Data Model A data model is a model that describes in an abstract way how data is represented in an information system or a database management system. • A data model defines syntax and semantics, i.e. – How can data be structured (syntax) – What does this structure mean (semantics) • Very generic term for many applications – Programming languages have their data models (e.g. C++ and Java have object-oriented data models) – Conceptual design methods (e.g. ER, UML) represent a data model – File formats either apply a data model (e.g. XML) or implement their own – Database management systems implement data(base) models Schallehn: Data Management for Engineering Applications Information System Design Phases Conceptual Models: Requirements ER, UML, EXPRESS-G Analysis Conceptual Logical Models: Design Relational, Object-oriented, Document-oriented, EXPRESS Logical Design Physical Models: SQL-92, SQL:2011, XML, JSON, C++, Physical Java Design Implementation Schallehn: Data Management for Engineering Applications Types of Data Models • Conceptual Models – Describing the concepts of the given Universe of Discourse and their relationships – Information requirements of system/users – Independent of final structure implementation – Often using graphical notation • Logical Models – Describes the logical structure of information (data) in the system to be developed – Independent of specific (database) systems or (programming) languages • Physical/Implementation Models – Describes all details of how information is represented Schallehn: Data Management for Engineering Applications The Relational Model (RM) • Developed since early 1970s based on mathematical theory of relations and operations performed on them (relational algebra) • SQL (Structured Query Language) as a strong standard to access relational databases • Relational Database Management Systems (RDBMS) implement RM, most often based on SQL • RDBMS are state of the art for database storage Schallehn: Data Management for Engineering Applications SQL/RM: Basic Concepts • Data is stored as rows/records (tuples*) in tables (relations) with values for each column (attribute) • Rows can be identified by special columns called primary keys, for which a unique value must exist • Foreign keys can be used to establish connections across data in different tables • Constraints can be specified to grant consistency * Terms in brackets relate to relational theory/mathematics Schallehn: Data Management for Engineering Applications SQL/RM: Simple Example PartID Name Weight SupplierID GT-876-140425 Plunger 143.5 1 FT-852-130707 Shaft 77.0 3 FT-855-140809 Bolt 15.7 1 TT-707-778 Case 22.8 2 SupplierID Name Location 1 Reed & Sons New York 2 CaseStudio Boston 3 ToolTime Austin Schallehn: Data Management for Engineering Applications SQL/RM: Tables Column PartID Name Weight SupplierID GT-876-140425 Plunger 143.5 1 Table FT-852-130707 Shaft 77.0 3 FT-855-140809 Bolt 15.7 1 Row TT-707-778 Case 22.8 2 Schallehn: Data Management for Engineering Applications SQL/RM: Primary Keys Primary Key PartID Name Weight SupplierID GT-876-140425 Plunger 143.5 1 FT-852-130707 Shaft 77.0 3 Primary Key Value FT-855-140809 Bolt 15.7 1 TT-707-778 Case 22.8 2 Schallehn: Data Management for Engineering Applications SQL/RM: Foreign Keys Foreign Key PartID Name Weight SupplierID GT-876-140425 Plunger 143.5 1 FT-852-130707 Shaft 77.0 3 FT-855-140809 Bolt 15.7 1 TT-707-778 Case 22.8 2 SupplierID Name Location 1 Reed & Sons New York 2 CaseStudio Boston 3 ToolTime Austin Schallehn: Data Management for Engineering Applications The Structured Query Language (SQL) • Language to access databases structured according to Relational Model – Developed based on RM – Introduces some minor differences to RM – Not a programming language • Consists of several parts, most importantly: – Actual query language to read data – Data Definition Language (DDL) to create (empty) databases, tables, etc. – Data Manipulation Language (DML) to insert, modify and delete data Schallehn: Data Management for Engineering Applications SQL: Query Language SELECT <columns> FROM <tables> WHERE <condition>; • Declarative language: – Result is described, not how it is computed – Actual execution can be optimized by DBMS • Typical structure: SFW-block (SELECT-FROM-WHERE) • Input as well as result are always tables • Used from programming languages via standardized or proprietary application programming interfaces (ODBC, JDBC, etc.) Schallehn: Data Management for Engineering Applications SQL: Query Language Example 1 SELECT name, weight FROM part WHERE weight > 50; Name Weight Plunger 143.5 Shaft 77.0 Schallehn: Data Management for Engineering Applications SQL: Query Language Example 2 SELECT p.name, s.name FROM part p, supplier s WHERE p.supplierid = s.supplierid AND s.name LIKE ‘Reed%’; Part.Name Supplier.Name Plunger Reed & Sons Bolt Reed & Sons Schallehn: Data Management for Engineering Applications SQL: Data Definition Language CREATE TABLE part ( partid INTEGER PRIMARY KEY, name VARCHAR(50) NOT NULL, weight DECIMAL(10,2), supplierid INTEGER REFERENCES supplier(supplierid) ); • DDL= Part of SQL language used to define schema elements (tables, constraints, views, etc.) Schallehn: Data Management for Engineering Applications SQL: Data Manipulation Language (DDL) INSERT INTO supplier VALUES (4,’Rex & Smith’, ‘Baltimore’); UPDATE supplier SET location=‘Woburn’ WHERE supplierid=2; DELETE FROM part WHERE supplierid=1; • DML = Part of SQL language to insert, modify and delete data Schallehn: Data Management for Engineering Applications Engineering and RDBMS • RDBMS often used for – Product Lifecycle Management (Product Data Management, Engineering Data Management) – Applications for generic tasks, e.g. Enterprise Resource Planning, Workflow Management Systems, Supply Chain Management, etc. • RDBMS less often or not used for – Direct structured storage of product definition data • Details in Section 4 Schallehn: Data Management for Engineering Applications Object-oriented Data Models • Enhanced semantic modeling – Allows more flexible and re-usable definitions – More semantic concepts add complexity to data model/languages • Developed gradually until major breakthrough in 1980s • Similar concepts of data modeling applied for numerous application fields in computer science, e.g. – Object-oriented Analysis and Design (e.g. UML) – Object-oriented Programming (e.g. C++, Java) – Object-oriented Databases (e.g. db4o, Versant) – Object-relational Databases (SQL since SQL:1999) – Object-oriented User Interfaces Schallehn: Data Management for Engineering Applications OO: Enhanced Semantic Modeling • Objects as instances (data) of classes • User-defined Classes as definitions (schema) of – The structure of objects with Attributes and Relationships – The behavior of objects by Methods (class functions) • Encapsulation to differentiate between appearance to use user of objects of classes (interface) and their internal structure and behavior (implementation) • Re-usability of definitions by Specialization among classes – Inheritance: specialized classes (subclasses) also posses the attributes, relationships and methods of the classes they were derived from (superclasses) – Polymorphism: objects of a subclass are also objects of the superclass and can be used accordingly Schallehn: Data Management for Engineering Applications OO: Attributes • Attributes represent properties of class Part objects of a class, for which an { object carries concrete values ... string name; • Defined based on data types int version_id; – Basic data types defined of Date lastModified; implementation model (e.g. ... int, float, char in C++) }; – Pre-defined complex types (e.g. string in C++) This and all following – User-defined complex types (e.g. examples on OO are in C++ classes for Address, Date, Coordinates, etc.) Schallehn: Data Management for Engineering Applications OO: Methods • Specification of behavior of objects in class Part { terms of functions on that object ... • Interface (Signature, declaration): Part(string n); void createNewVersion(); – Specifies how the method can be used ... – External view of the method }; – Name, parameters and return value ... • Implementation (definition): – Provides executable source code for Part::Part(string n) method { name = n; – Internal view of the methode version_id = 1; • Interface and implementation } may be separated (e.g. in C++) void Part::createNewVersion() • Constructors as special methods to { version_id++; create objects of that class } Schallehn: Data Management for Engineering Applications OO: Relationships class Part • 1:1 and N:1 Relationships { between different objects ... Engineer* responsibleEngineer; most often represented by ... }; pointers (physical address, e.g. C++) or references class Engineer (logical, e.g. Java) { ... • Bidirectional, 1:N and N:M string name; string department; relationships require set<Part*> designedParts; ..