## 15 EOAttribute class ¶

### 15.1 overview ¶

An attribute typically maps a table column to an instance variable, in which case the attribute is a class property. Some attributes represent foreign keys which are used to create realationships yet do not correspond to a property in the enterprise object. Other attributes may represent primary keys which needn’t be class property either. In fact some parts of framework work more smoothly if primary key attributes and foreign key attributes are not class properties.

Attributes typically contain:

1. A name
2. A column name
3. An adaptor value type
4. An external type
5. A value type
6. A value class name
7. A value factory method name
8. a factory method argument type

Some additional properties an attribute may have:

1. Read only
2. Allows null
3. Width
4. Precision
5. Scale

### 15.2 Name ¶

The attributes name when the attribute is a class property is used as the key when doing key value coding on an enterprise object.

It also uniquely identifies the attribute in its entity there many not be an attribute with the same name as another attribute or relationship in an entity.

### 15.3 Column name ¶

The adaptor uses the column name in generating SQL.

### 15.4 Adaptor value type ¶

Indicates the type of the attribute as contained in the database

Valid adaptor value types are:

1. EOAdaptorNumberType
2. EOAdaptorCharactersType
3. EOAdaptorBytesType
4. EOAdaptorDateType

Corresponding to numerical, string, raw data, and date value types.

### 15.5 External type ¶

An external type is a string representing an adaptor specific database type different adaptors may use different names where the PostgreSQL adaptor might use ’char’. The SQLite3 Adaptor might use ’TEXT’

it gives you full control on how the data is stored in the specific adaptor where the adaptor value type allows you to specify a few generic values.

### 15.6 Value type ¶

Value types are a string with a single character such as ’f’ for floats ’c’ for chars a full list of the standard types is available in the GDL2 API reference for EOAttributes -valueType method.

The value type allows you to further refine the adaptor value type where EOAdaptorNumberType might represent a integer, float, or double type.

### 15.7 Value class name ¶

The value class name specifies the class which will be present in an Enterprise Object containing the attribute.

A property of this class will be instantiated when a field is retrieved from the database, similarly a instance of this will be converted into the external type when being sent to the datbase server.

### 15.8 Value factory method name ¶

When the Value Class Name is a custom object for instance NSImage created from a blob of data. The value factory method name denotes the initializer for the class, used to create a new instance of the custom class.

The value class name is an NSString representing a selector accepting a single argument suitable for passing to the NSSelectorFromString function.

### 15.9 Value factory argument type ¶

This is the type of the argument sent to the value factory method name.

Valid types are

1. EOFactoryMethodArgumentIsNSData
2. EOFactoryMethodArgumentIsNSString
3. EOFactoryMethodArgumentIsBytes