中文网站
  Advanced Search
Read the latest Blogs from IT professionals in the field. Read and write community created documents. Need IT help? Ask our staff. Connect with your peers. Check our Tech Shop for posters, books and software tools. Home

1.3.1 Database System: Object-based Logical Models

1. Object-based logical models:

Describe data at the conceptual and view levels.

Provide fairly exible structuring capabilities.

Allow one to specify data constraints explicitly.

Over 30 such models, including

  • Entity-relationship model.

  • Object-oriented model.
  • Binary model.
  • Semantic data model.
  • Infological model.
  • Functional data model.

2. At this point, we'll take a closer look at the entity-relationship (E-R) and object-oriented models.

The E-R Model

1. The entity-relationship model is based on a perception of the world as consisting of a collection of basic objects (entities) and relationships among these objects.

  • An entity is a distinguishable object that exists.
  • Each entity has associated with it a set of attributes describing it.
  • E.g. number and balance for an account entity.
  • A relationship is an association among several entities.
  • e.g. A cust acct relationship associates a customer with each account he or she has.
  • The set of all entities or relationships of the same type is called the entity set or relationship set.
  • Another essential element of the E-R diagram is the mapping cardinalities, which express the number of entities to which another entity can be associated via a relationship set.

We'll see later how well this model works to describe real world situations.

2. The overall logical structure of a database can be expressed graphically by an E-R diagram:

  • rectangles: represent entity sets.
  • ellipses: represent attributes.
  • diamonds: represent relationships among entity sets.
  • lines: link attributes to entity sets and entity sets to relationships.

The Object-Oriented Model

1. The object-oriented model is based on a collection of objects, like the E-R model.

  • An object contains values stored in instance variables within the object.
  • Unlike the record-oriented models, these values are themselves objects.
  • Thus objects contain objects to an arbitrarily deep level of nesting.
  • An object also contains bodies of code that operate on the the object.
  • These bodies of code are called methods.
  • Objects that contain the same types of values and the same methods are grouped into classes.
  • A class may be viewed as a type de nition for objects.
  • Analogy: the programming language concept of an abstract data type.
  • The only way in which one object can access the data of another object is by invoking the method of that other object.
  • This is called sending a message to the object.
  • Internal parts of the object, the instance variables and method code, are not visible externally.
  • Result is two levels of data abstraction.

For example, consider an object representing a bank account.

  • The object contains instance variables number and balance.
  • The object contains a method pay-interest which adds interest to the balance.
  • Under most data models, changing the interest rate entails changing code in application programs.
  • In the object-oriented model, this only entails a change within the pay-interest method.

2. Unlike entities in the E-R model, each object has its own unique identity, independent of the values it
contains:

  • Two objects containing the same values are distinct.
  • Distinction is maintained in physical level by assigning distinct object identi ers.