representing information. data models a data model is a precise description of information content...
Post on 21-Dec-2015
215 views
TRANSCRIPT
Data Models
A data model is a precise description of information contentTypes of data models
Conceptual (high-level): in terms that users will understandLogical: in terms that a relational database system will understand (close to the way data is stored)Physical (low-level, how data is actually stored): in terms of the underlying computer hardware and operating system (memory/file system)
Data Models
A Schema is a data model that is intended to be used with a specific database system
External schemas are defined for the users of a database
Logical schema defines the representation as a collection of tables that are stored in a database server
Internal schema defines the representation used by the database server to store the tables in memory or files
External level
Internal to logical mapping
Logical to external mappings
disk
Internal schema Internal level
External schema 1 External schema 2 External schema 3
Logical schema Logical level
Databasetables
Data Models
Distinction between a schema and actual database: intension vs. extension
Populating a database
Requirements
In this phase database designers gather information about the database system in need
Database designers model the database according to user requirements
Database attributes and characteristics conform to users’ actual “ vocabulary”
Organizing Information
Entity An abstraction of the object that contains those characteristics important to the information system
Entity classThe common characteristics that represent a set of entities
AttributeA characteristic/property that helps to describe an object
Attribute valueThe value of a particular characteristic
Organizing Information
Examples
Entity: A customer, or the characteristics of a customer that are of interest
Entity class/type: All of the potential customers, or the information about them
Attribute: hair color or last name
Attribute value: hair color is brown or last name is ‘Breaux’
Examples of Entity Classes
Entity Class Description
Customer A customer of the business
Video An item in the rental inventory
Employee A person who works in one or more stores
Store One of the retail outlets of BigHit Video
Rental The rental of a video by a customer for a specific period and cost
PurchaseOrder
A request to purchase an item
Attributes
An attribute has: Name, Type, Restriction, Description
Domain of an attribute: set of all possible values
Attribute Single valued /simple/atomicMulti-valued (each element is a possible value): college degree, car colorComposite (the whole is one value): consists of several atomic attributes (date, address)
Examples
Attribute Type Restrictions on Values
Description Sample Value
title String Unbounded The title of an item
Annie Hall
ssn String 9 digits (0–9)
A Social Security number
211009008
accountId Number 4 byte integer
The identifier of a customer account
101
Address Composite 2 strings Street, city, st., Zip
….
otherUsers Set Set of strings of 30 characters
Names of other people authorised to use the account
Jeremiah Block
Kenneth Block
Key Attributes
A key attribute is an attribute that uniquely identifies a single entity within the class
Examples Employee : SSN Book : ISBN Customer : AccountId
A key may be a composite attribute: Full Name
Attribute Constraints
Key Constraint: The system respects this constraint by rejecting an entity with an existing key
Null Constraint: the value can (not) be NULL(unknown, not applicable)
Derived: value not entered but computed based on other attributes’ values
Relationships
A relationship type between 2 entity classes represents the possibility that two entities may be related (x-product)
A customer may rent a video
A relationship (or relationship instance) is a connection between 2 entities (actual tuple)
Customer Jane Block rents the video with videoId 90987
To maintain flexibility in relationships, relationship types are not defined as attributes
The customer accountId is not an attribute of the Video entity class
Example (Customer and Video)
Account ID: 101 video ID: 90987
Date: January 9, 2002
Cost: $2.99
Jane Block1010 Main St.Apopka, FL 30458
Elizabeth Date due: January 11, 2002
Constraints on RelationshipsA relationship type may be limited in how many relationships an object may haveThe cardinality of a relationship type may be
One-to-one: Each object of a class may have no more than one object of the other classOne-to-many: One of the classes allows and entity to have any number of related entities, but the other class restricts its entities to be related to no more than one entity.Many-to-many: Entities of both classes may have any number of related entities of the other class.
Other Constraints
Min/Max constraints
Mandatory Participation Constraint and Optional Participation Constraint
Higher-order relationships
A relationship can involve more than two entities
Example: Store-Video-Supplier relationship
Example(Case in Point)
Determining entity classes, attributes and relationship types for BigHit Online video salesProcess
Evaluate statement of goals for information systemDefine entity classesDefine attributes for entity classesDefine relationship typesDetermine cardinalities of relationship rolesAdd attributes to relationship types as necessaryEvaluate entity classes, attributes, and relationship types for clarity, accuracy, and completeness
Example
Entities:
Customer (key: account , last name, first name, address, email, credit card, password)
Movie (key: id, title, genre, length)
Sale (key: id, cost, date, credit card)
Shopping Cart (key: id, date)