Relational Database Design

At this point, we have a theoretical analysis of the HR database. Before we create a physical implementation, we need to consider how it will be implemented. This is the step in which we decide which data types we will use for the attributes, determine how to constrain those data types, and define external primary keys, among other things. Let’s start by deciding which data types to use.

Selecting Data Types

One of the beautiful things about Oracle is that it does not have presentation data types. There is no money type, for example. Not having presentation data types keeps things simple. The number of data types you need to work with is kept to a bare minimum. With Oracle, you get a small number of data types that allow you to work with the following four basic types of data:

  • Binary

  • Character

  • Date

  • Numeric

For binary data, you have the following Oracle data types to work with:

RAW

A varying-length binary type that can hold up to 2 KB

LONG RAW

A varying-length binary type that can hold up to 2 GB

BLOB

A varying-length binary type that can hold up to 4 GB

BFILE

An external file that can hold up to 4 GB

For character data, you have the following types at your disposal:

CHAR (or NCHAR)

A fixed-length character type right-padded with space characters up to its constraining size

VARCHAR2 (or NVARCHAR2)

A varying-length character type that can hold as many characters as will fit within its constraining size

LONG

A varying-length character type that can hold up to 2 GB ...

Get Java Programming with Oracle JDBC now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.