SPS Home    >   Dgreath    >   RDBMS    >   Entities & Attributes

DATABASE ENTITIES & ATTRIBUTES

Overview:
Entities are anything that have two essential characteristics. First, entities must be uniquely identifiable, and second, entities must be describable. A database is simply a collection of related entities consisting of lists of unique instances. An individual entity within a database is referred to as an instance. Entities consist of a list of two or more attributes. If an attribute serves to identify an instance, it is a key attribute. Attributes that describe an instance are non-key attributes. Each attribute contains a datum or fact about the instance. Key attributes serve to create relationships between database tables. Single table databases are flat databases, however, those with two or more tables having defined relationships are known as relational databases. The names of databases, entities, and attributes are their identifiers. A database table, each of its rows (instances), and each of its columns (attributes) are considered individual database objects (dbo) and can be manipulated and interrogated in a variety of ways.

Domain Integrity:
Domain integrity, the method of ensuring the accuracy of the data contained in the database, is accomplished by the configuration of each attribute. Factors include datatype, length, range of values, nullability, and default value. There are six categories of datatypes: exact numeric, approximate numeric, date and time, character, binary, and special. Length is concerned with the number of bytes allowed for the attribute. Nullability concerns whether or not an attribute can be set to null or unknown values. Default values are preset values that are inserted into the attribute when nulls are not allowable.

Identifier Naming Conventions:
By convention, entities are expressed as plural nouns (e.g. CUSTOMERS or VENDORS), and attributes are expressed as singular nouns (e.g. NAME or PHONE). A complete specification consists of the entity identifier combined with the attribute identifier, separated by a period (e.g.  CUSTOMERS.NAME). Identifiers that require multiple words are generally separated by underscores (e.g. HOME_ADDRESS).

Identifier Naming Requirements:
Identifiers for database objects (dbo) must conform to the following requirements.

  1. An identifier must not exceed 128 characters (bytes) in length.
  2. The first character must be either a letter [A-Z], underscore [_], asperand [@], or octathorpe [#].
  3. Remaining characters must be either letters [A-Z], numbers [0-9], underscores [_], asperands [@], or octathorpes [#].
  4. An identifier cannot contain spaces [ ] or other special characters not listed above.
  5. Any identifier that does not conform to these rules must be delimited with either
    single quotes [' '] or square brackets [ ].
  6. Any identifier that does conform to these rules may be delimited with either single quotes [' '] or square brackets [ ].
  7. No identifier can be a reserved SQL keyword.

Notation Methods:
Two common methods of diagramming entities and attributes are shown below: 

Manual notation method:

ENTITY (attribute1* attribute2 attribute3 attribute4)

Note that the primary key is underlined and asterisked and all foreign keys are underlined.

Entity/Relationship method:

ENTITY
attribute1*
attribute2
attribute3
attribute4

Note: an E/R Diagram consists of three boxes. The entity name goes in the top box, key attributes (underlined) in the middle box, and non-key attributes in the lower box. The primary key is also asterisked.