At 02:35 PM 1/16/02 -0800, David Torre wrote:
>-ERROR- The referenced table artist_keywords does not
>have a compatible Primary Key or Unique. (2770)
David,
Before defining PRIMARY and FOREIGN KEY constraints, decide
which column or columns and which tables are best suited
for the PRIMARY KEY. The column or columns selected should
be the ones that uniquely identify the row from other rows
in the table, and the table should be the one where that
value is first entered into the database and is unique.
Linking columns are generally good candidates for PRIMARY,
FOREIGN KEY constraints. For example, in the Concomp sample
database, the CustID column is used to link data in the
Customer table with data in the Contact table. Since a
record is first entered into the Customer table, and when
data is entered into the Contact tables a matching record
must already exist in the Customer table, the CustID column
in Customer becomes the PRIMARY KEY. The CustID column in
Contact become FOREIGN KEY referencing the Customer table
PRIMARY KEY.
You can easily achieve this task by using the ENHANCED
Object Manager/Data Designer option of The Glorious R:BASE
2000 (version 6.5++), Build:1.850xRT03.
Using the powerful R:BASE command language, you should
define the table(s) with constraints first. Then, use the
ALTER TABLE TableName ADD PRIMARY KEY option to add PRIMARY,
FOREIGN keys.
Simple Example:
-- Step 1. Define Database and Create Table(s)
CREATE SCHEMA AUTHOR Sample NONE
CREATE TABLE `Customer` +
(`CustID` INTEGER NOT NULL +
('Customer ID Number Cannot be NULL.'), +
`Company` TEXT (40), +
`CustAddress` TEXT (30), +
`CustCity` TEXT (20), +
`CustState` TEXT (2), +
`CustZip` TEXT (10), +
`CustPhone` TEXT (12), +
`ModLevel` INTEGER)
CREATE TABLE `Contact` +
(`CustID` INTEGER, +
`ContFName` TEXT (10), +
`ContLName` TEXT (16), +
`ContPhone` TEXT (12), +
`ContInfo` NOTE)
-- Step 2. Add constraint(s)
ALTER TABLE `Customer` ADD PRIMARY KEY +
(`CustID`) +
('The Customer ID Number must be unique for this table.')
ALTER TABLE `Contact` ADD FOREIGN KEY +
(`Custid`) REFERENCES `Customer`
Have Fun!
Very Best Regards,
Razzak.
===================================-============================
Official R:BASE List Server: mailto:[EMAIL PROTECTED]
RBTI Events/Training: http://www.rbase2000.com/events
R:DCC Members: http://www.rbase2000.com/rdcc
================================================================
R:BASE, Oterro & R:Tango are registered trademarks of RBTI.
==================================-=============================
================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: INTRO rbase-l
================================================
TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: UNSUBSCRIBE rbase-l