Ask a Question related to Coldfusion Database Access, Design and Development.
-
Paulo Weiler #1
Referential Integrity
I've got a CONTACTS table that is used to store different
types of contacts and therefore relates to many different
tables (CUSTOMERS, SITES,etc). I can EITHER keep a
relationship with each of this tables, creating columns at
the CONTACTS table to store each foreign key, OR I can
keep two columns, REFERENCED_TABLE and
REFERENCED_TABLE_ID, valid for any related table and then
manage the referential integrity using triggers. What
solution do you think is the best ?
Many thanks, Paulo Weiler
Paulo Weiler Guest
-
Integrity constraint violation
I'm getting the following error when I try to insert the following code: Code: <cfquery datasource="#data_source#"> INSERT INTO... -
custom integrity check
Hi, I have the following table as a link table between my 'cats' table and my 'items' table. Every item must have at least one cat and exactly... -
File integrity checkers
Roberto wrote: Sounds like you need portability and centralized control. Tripwire is the hands down favorite and usually first mentioned,... -
Honesty & Integrity = Cash
Honesty & Integrity = Cash ***I have not tried this yet, but I think it is worth a $7.00 investment. I spend more than that for lunch!*** I'd... -
SystemStackError comparing self-referential structures
irb(main):021:0> a = ; a << a => ] irb(main):022:0> b = ; b << b => ] irb(main):023:0> a == b SystemStackError: stack level too deep I... -
Jacco Schalkwijk #2
Re: Referential Integrity
Always use Foreign Keys for referential integrity, unless you really need
the added functionality that triggers can provide. Triggers are a lot slower
and a more difficult to maintain.
You can create a script (if you have a good naming convention) to generate
all the Foreign keys:
SELECT 'IF EXISTS(SELECT * FROM information_schema.constraints WHERE
constraint_name = FK_' + c.table_name + '_contacts)'
+ CHAR (13) +
'ALTER TABLE ' + c.table_name + ' DROP CONSTRAINT FK_' + c.table_name +
'_contacts'
+ CHAR (13) +
'ALTER TABLE ' + c.table_name + ' ADD CONSTRAINT FK_' + c.table_name +
'_contacts'
+ CHAR (13) +
'FOREIGN KEY (contact_id) REFERENCES contacts (contact_id)'
+ CHAR (13) +
'GO'
+ CHAR (13)
FROM information_schema.columns c
INNER JOIN information_schema.tables t
ON c.table_name = t.table_name
WHERE c.column_name = 'contact_id'
AND c.table_name <> 'contacts'
AND t.table_type = 'base table'
Run this in Query Analyzer with 'results in Text'.
--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.
"Paulo Weiler" <europaulo02@yahoo.com> wrote in message
news:0a3a01c34793$69421950$a101280a@phx.gbl...> I've got a CONTACTS table that is used to store different
> types of contacts and therefore relates to many different
> tables (CUSTOMERS, SITES,etc). I can EITHER keep a
> relationship with each of this tables, creating columns at
> the CONTACTS table to store each foreign key, OR I can
> keep two columns, REFERENCED_TABLE and
> REFERENCED_TABLE_ID, valid for any related table and then
> manage the referential integrity using triggers. What
> solution do you think is the best ?
> Many thanks, Paulo Weiler
Jacco Schalkwijk Guest
-
weblover #3
Referential Integrity
Hi
how to set the referential integrity between 2 tables using enterprise manager (microsoft SQL SERVER).. i tried and the tab doesn't allow me to choose. pls.help.
thanks
sree
weblover Guest
-
The ScareCrow #4
Re: Referential Integrity
You can do this in 2 ways.
1. Create a diagram for the db
Expand the db and double click the diagrams option
2. Open a table in design mode, right click on a column and select the option
required from the menu
Ken
The ScareCrow Guest



Reply With Quote

