Book Image

Creating your MySQL Database: Practical Design Tips and Techniques

By : Marc Delisle
Book Image

Creating your MySQL Database: Practical Design Tips and Techniques

By: Marc Delisle

Overview of this book

For most of us, setting up the database for an application is often an afterthought. While you don't need to be a professional database designer to create a working application, knowing a few insider tips and techniques can make both the process easier and the end result much more effective. This book doesn't set out to make you an expert in data analysis, but it does provide a quick and easy way to raise your game in this essential part of getting your application right.
Table of Contents (12 chapters)

Rules for Table Layout


There can be more than one correct solution, but any correct solution will tend to respect the following principles:

  • each table has a primary key

  • no redundant data is present when considering all tables as a whole

  • all columns in a table depend directly upon all segments of the primary key

These principles will be studied in details in the following sections.

Primary Keys and Table Names

Let's start by defining the concept of a unique key. A column on which a unique key is defined cannot hold the same value more than once for this table. The primary key is composed of one or more columns, it is a value that can be used to identify a unique row in a table. Why do we need a primary key? MySQL itself does not force us to have a primary key, neither a unique key nor any other kind of key, for a specific table. Thus MySQL puts us under no obligation to follow Codd's rules. However, in practice it's important to have a primary key; experience acquired while building web interfaces...