190 likes | 399 Vues
Conceptual Modelling. Entity Relationship Model. Overview. Entities, Attributes and Relationship modelling Generating a Relational Database for an EAR model Tutorial - Using the QSEE case tool. Abstraction Layers. WHAT. Conceptual What data is held An Image and its meta-data
E N D
Conceptual Modelling Entity Relationship Model
Overview • Entities, Attributes and Relationship modelling • Generating a Relational Database for an EAR model • Tutorial - Using the QSEE case tool
Abstraction Layers WHAT • Conceptual • What data is held • An Image and its meta-data • Entity-Relationship model (ERM) • Logical • How data is organised in storage • Block and Directory structure • Tables, keys • Physical • How data is stored in bits • JPEG as a stream of bytes • A Database as files and records stored in a DBMS-specific format Realisation (Refinement Reification) (Engineering, Model-Driven development Abstraction (Reverse Engineering) HOW
ER Model • This modelling language allows a very small vocabulary: Just as English has nouns, verbs, adjectives, pronouns.. • ER models have only 3 core concepts • Attribute – a simple, atomic data item like a date, a name, a number [also called Property or Field] • Entity – a group of attributes which are all related to the same thing [also called Entity Type or Class] • Relationship – a relationship between Entities.
Entities and Instances Data Instances (entity instances, objects) Employee SMITH Employee ALLEN Schema isA isA Entity (entity type, class) Employee
MMS application • A simple web application which allows an account holder to send a photo from a mobile phone to a web site to be added to a photo gallery • Server Technology • Data storage in MySQL relational database • Scripting language : PHP
MMS Photo Gallery Documentation mmsmail@cems.uwe.ac.uk MMS mailbox Originating phoneno mime2db.php MySql database mimedecode.php mms1 php scripts index.php getpage.php getimage.php
MMS Photo : EAR diagram Entity Each Photo created by exactly one Member Relationship Attribute Or none Each Member has created many Photos Primary key Data Type Diagram generated by QSEE
Other conceptual models • ERM is not the only conceptual model in use • Object-role model (ORM) drop the distinction between attributes and relationships – its all relationships. • Single level models (RDF) drop the distinction between type and instance.
Case Tool - QSEE • is a free download for individual use • is available in the lab (older version ) • enables a wide range of diagram types to be created • UML • Data flow diagrams … • Entity-relationship diagram • With generation of SQL for creating a database (with some fixes - use Perl script to clean up)
Entity (type) • Typically represents a type of thing –person, department, photo with properties of interest • Similar to a Class in Object-Orientation (but no methods) • Has a name • Name becomes the name of the table in a database • I prefer a singular noun – Employee, Department. The table will contain a varying number of entity instances but the Entity Type is singular • Has attributes or properties (which might become fields or columns in a database) • Entity instances are related (linked) to other entity instances – relationships • Has an Annotation (in QSEE) • Text to describe the scope of this type (what things can be one of these), the meaning and usage, a typical example.
Attribute • Name • Must be unique within the Entity • Avoid SQL reserved words • Type (data type) • SQL provides a set of available data types – essential ones are: • integer – a whole number • numeric – number with decimal part • character – fixed length string • varchar – variable length string • date – hold dates like 2005-10-14 • blob – a very large field – such as a JPEG image • Primary Key • An attribute(or several) which uniquely identify each instance of the entity within the set of all instances.
Relationships in QSEE • Name • Names the relationship • There can be multiple relationships between the same entity types e.g, • Employee –Department • Works in • Is manager of • Has worked in • Must never work in • Relationship ends (roles) can be named too – I prefer to use this than relationship names which need a direction • Cardinality • from source (start) to destination (end) • Optional • Identifier • For 1-M, does the source (partly) identify the destination • Annotation • Text describing the meaning of this relationship
Relationship CARDINALITY M1 M2 M4 P1 P4 P5 P3 P7 One-one One-many Member Photo Many-many 1..n 1..n
It is hard to get this notation the right way round. • Always read it both ways • Every X is related to how many Y’s? • Every Y is related to how many X’s?
Relationship OPTIONALITY M1 M3 M2 P1 P4 P5 P7 P3 P7 One-many Member Photo
Class Exercise - KML • A Folder has a name and contains zero, one or more PlaceMarks and some Styles • A Placemark has attributes of : • A name • A description • A position defined by its longitude, latitude and Altitude, each represented by a signed decimal number • A Style defines the appearance of a placemark – the symbol to show, the size, the foreground and background colour. • Each Placemark has a Style • Draw an ERM for this simplified description of a KML Folder.