Working with structured types
In an object-oriented design, we have business objects as entities and each entity has a set of attributes. A structured type is a user-defined special data type, consisting of one or more data types. To represent an entity in DB2, we can use structured types.
A structured type is a user-defined data type consisting of one or more data types defined as its attributes. For example, in a school, a room can be one entity and its attributes can be length, width, and height. In this example, we can create a structured type as room
and define its attributes as width, height
, and length
. Once we have created a structured type, we can use it as a regular built-in data type. DB2 also provides ways to define its behavior. In this recipe, we will see how to create structured types and use them in our applications.
Getting ready
In this recipe, we will take a scenario of a high school where we have faculty members and students.
How it works...
1. Creating a structured type...