View Single Post
  #3  
Old February 11th, 2005, 03:38 PM
onedaywhen
external usenet poster
 
Posts: n/a
Default


John Vinson wrote:
"Shel" wrote:

User1 is always entering data
for Cats. User2 is always entering data for Dogs. User3 is always

entering
data for Fish.

The question: What is the easiest way to automatically fill in the
"AnimalType" field based on which user is entering the record?


If each user is working from their own PC, linked
to a shared backend database (as they should be, if you have multiple

users!)
then you can have each user set the appropriate Default property for

this
field.


Unlike the subject matter in another thread, I can't imagine many
shared attributes between the AnimalTypes (isn't there an oft heard
phrase about the difference between cats and dogs ... what then fish?!)
So perhaps there is value in modelling each as a separate table, with a
base table for the (few?) common attributes. Then you could present a
VIEW (Query, Form, whatever) specific to each table/AnimalType/user.

Here's a structure I stole from somewhere. John, you get to practice
your new-found Jet CHECK constraints g:

CREATE TABLE Animals
(AnimalID CHAR(10) NOT NULL PRIMARY KEY,
AnimalType CHAR(4) NOT NULL,
CHECK(AnimalType IN ('CAT', 'DOG','FISH')),
UNIQUE (AnimalID, AnimalType),
common columns);

CREATE TABLE Cats
(AnimalID CHAR(10) NOT NULL PRIMARY KEY,
AnimalType CHAR(4) DEFAULT 'CAT' NOT NULL, CHECK(AnimalType = 'CAT'),
UNIQUE (AnimalID, AnimalType),
FOREIGN KEY (AnimalID, AnimalType)
REFERENCES Animals(AnimalID, AnimalType)
ON UPDATE CASCADE
ON DELETE CASCADE,
cat specific columns);

CREATE TABLE Dogs
(AnimalID CHAR(10) NOT NULL PRIMARY KEY,
AnimalType CHAR(4) DEFAULT 'DOG' NOT NULL,
CHECK(AnimalType = 'DOG'),
UNIQUE (AnimalID, AnimalType),
FOREIGN KEY (AnimalID, AnimalType)
REFERENCES Animals(AnimalID, AnimalType)
ON UPDATE CASCADE
ON DELETE CASCADE,
dog specific columns);

CREATE TABLE Fishes
(AnimalID CHAR(10) NOT NULL PRIMARY KEY,
AnimalType CHAR(4) DEFAULT 'FISH' NOT NULL,
CHECK(AnimalType = 'FISH'),
UNIQUE (AnimalID, AnimalType),
FOREIGN KEY (AnimalID, AnimalType)
REFERENCES Animals(AnimalID, AnimalType)
ON UPDATE CASCADE
ON DELETE CASCADE,
fish specific columns);

Jamie.

--