At 11:10 PM 5/24/2013, Tom Hart wrote:

I am in the process of redoing my database that I've used for over 10 years,
just trying to use logic in naming, correct syntax, etc.  I have numerous
tables that hold data to use to fill fields from popup menus and just wanted
to know if it is better to set the field as a PK or unique, they do not
reference other tables so there are no foreign keys.  Is one way better that
the other, just curious


Tom,

One of the strengths of R:BASE is to provide automatic data integrity and
referential integrity using constraints. Constraints are a part of the
database structure and are automatically enforced.

The constraints that can be defined are Primary Key, Foreign Key, Not Null
and Unique Key.

Here's what you need to know about the Primary Key (PK) vs. Unique Key (UK):

A primary key is the column, or set of columns, that uniquely identifies a
row in a table. In other words, it is a set of values that distinguishes one
row from another. This can be something like an Employee ID column in an
Employee table or it could be a combination of the Customer's ID and the
Customer's Phone number. Every table will have a column or set of columns
that identify a row, but not every table will have a defined primary key.

. A primary key cannot be defined if any one of the columns included in
  the desired key already have null or duplicate values.

. Defining a primary key automatically enforces NOT NULL and UNIQUE
  constraints on the column.

. A primary key definition can be used instead of a rule to prevent duplicates,
  and will be faster.

. R:BASE automatically builds an index on the specified column(s) when a primary
  key is defined

A Unique Key constraint requires that the data values in the column be unique,
i.e. the column cannot contain duplicate values. By definition, the column must
also be defined as NOT NULL.

. A unique constraint can replace a "Require a unique value" rule. A unique
  constraint also automatically builds an index.

. The unique constraint can be defined through the Data Designer (RBDefine) or
  the R> prompt using either the CREATE TABLE or ALTER TABLE command.

For example, ALTER TABLE tblname ALTER COLUMN colname datatype NOT NULL UNIQUE

Very Best R:egards,

Razzak.

www.rbase.com
www.facebook.com/rbase
--- RBASE-L
================================================
TO POST A MESSAGE TO ALL MEMBERS:
Send a plain text email to [email protected]

(Don't use any of these words as your Subject:
INTRO, SUBSCRIBE, UNSUBSCRIBE, SEARCH,
REMOVE, SUSPEND, RESUME, DIGEST, RESEND, HELP)
================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: INTRO
================================================
TO UNSUBSCRIBE: Send a plain text email to [email protected]
In the message SUBJECT, put just one word: UNSUBSCRIBE
================================================
TO SEARCH ARCHIVES:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: SEARCH-n
(where n is the number of days). In the message body, place any text to search for.
================================================


Reply via email to