Conceptual Modelling

Entity Relationship Model

Attributes and Relationship modelling • Generating a Relational Database for an EAR model • Tutorial .Using the QSEE case tool . Overview • Entities.

Abstraction Layers • Conceptual – What data is held Realisation • An Image and its meta-data (Refinement • Entity-Relationship model (ERM) Reification) • Logical (Engineering. – How data is organised in storage Model-Driven • Block and Directory structure development • Tables. keys Abstraction • Physical (Reverse – How data is stored in bits Engineering) • JPEG as a stream of bytes • A Database as files and records stored in a DBMS-specific format .

atomic data item like a date. • ER models have only 3 core concepts – Attribute – a simple. ER Model • This modelling language allows a very small vocabulary: Just as English has nouns. verbs. adjectives.. pronouns. 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. a name. .

SMITH ALLEN objects) Schema isA isA Entity (entity type. Entities and Instances Data Instances Employee Employee (entity instances. 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.php getpage.uk MMS mailbox Originating phoneno mime2db.ac.php mms1 php scripts index.uwe.php getimage.php .php MySql database mimedecode.

MMS Photo : EAR diagram Entity Each Photo created by exactly one Member Relationship Attribute Or none Each Member has Primary key created many Photos 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. .

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  . Case Tool .use Perl script to clean up) .

a typical example. 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. 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). Department. the meaning and usage. Entity (type) • Typically represents a type of thing –person. department. .

. 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.

g. does the source (partly) identify the destination • Annotation – Text describing the meaning of this relationship . Relationships in QSEE • Name – Names the relationship • There can be multiple relationships between the same entity types e. – 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.

..n 1.n . Relationship CARDINALITY M1 M2 M4 P1 P4 P5 P7 P3 One-one One-many Member Photo Many-many 1.

– Always read it both ways • Every X is related to how many Y’s? • Every Y is related to how many X’s? .• It is hard to get this notation the right way round.

Relationship OPTIONALITY M1 M3 M2 P1 P4 P5 P7 P7 P3 One-many Member Photo .

QSEE .

the foreground and background colour. the size.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. . • Each Placemark has a Style • Draw an ERM for this simplified description of a KML Folder. Class Exercise .