If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Views and RI

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-06-04, 00:26
byrmol byrmol is offline
Registered User
 
Join Date: Mar 2003
Location: Australia
Posts: 59
Views and RI

This may seem like a strange question but....

I was modelling a game of chess and came up with this representation for the chess board..

GameBoard
X TINYINT NOT NULL CHECK(X BETWEEN 1 AND 8)
Y TINYINT NOT NULL CHECK(Y BETWEEN 1 AND 8)
KEY(X,Y)

I then created a view that returns a single column displaying the chess notation for these corordinate eg. a1,a2..h8

I obviously have another table (Moves) which has the current Piece and what square it currently is on and I would have liked to enforce the "square" value via RI between the GameBoard and Move.

I quickly realised that I had made that classic logical/physical mistake in regards to this. ie: In the logical model Square is a type with 2 representations, X,Y and Notation. In the end I simply added a rather lengthy CHECK constraint on the square column in the Moves table...

But it did raise may interest..

Is there anything in the relational model that prohibits using a view in a RI constraint?
Reply With Quote
  #2 (permalink)  
Old 02-06-04, 08:39
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: Views and RI

Don't have my C J Date books to hand, but I don't think there is. The foreign key "references" constraint is really just a convenient shorthand for a database constraint like "FORALL child EXISTS (parent WHERE parent.pk = child.parent_fk)". I don't recall any prohibition on using views in database constraints in general, and can't see any reason for there being any.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On