Book Image

Troubleshooting PostgreSQL

Book Image

Troubleshooting PostgreSQL

Overview of this book

Table of Contents (17 chapters)
Troubleshooting PostgreSQL
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Deciding on data types and structure


After this brief introduction to organizing columns, it makes sense to discuss various other issues, such as choosing the right data type and normalization. Normalization is a standard technique to organize data and it has proven to be essential over the years. The idea is to avoid redundancy to ensure that changes only have to be made in one place. To make your database project a success, deciding on proper types is essential and will help to prevent a great deal of trouble later on in the project. The goal of this chapter is to make you aware of the potentials of using the right types.

Finding the right type

Finding the right data type sounds easy. However, there is a lot to consider, and there are some issues that might actually cause problems.

varchar versus text

The first two types to be compared are varchar and text. Have you ever seen a data structure like this?

test=# CREATE TABLE t_product (
  prodnr     int,
  name       varchar(20),
  description...