Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS SQL DAG Graph

Status
Not open for further replies.

timgerr

IS-IT--Management
Jan 22, 2004
364
US
Hello all,
I have a question about Directed acyclic graphs. I am new to Microsoft SQL server coming from MySql. The reason why I am now using MS SQL is the need for nodle graphs in a relational database. I have been reading so much on this, I really need this to work. I have been trying this from and I cannot get anything to work. I am just trying to create a few tables:
Code:
CREATE TABLE nodes (
id INTEGER PRIMARY KEY,
name VARCHAR(10) NOT NULL,
feat1 CHAR(1), -- e.g., age
feat2 CHAR(1) -- e.g., school attended or company
);

CREATE TABLE edges (
a INTEGER NOT NULL REFERENCES nodes(id) ON UPDATE CASCADE ON DELETE CASCADE,
b INTEGER NOT NULL REFERENCES nodes(id) ON UPDATE CASCADE ON DELETE CASCADE,
PRIMARY KEY (a, b)
);
CREATE INDEX a_idx ON edges (a);
CREATE INDEX b_idx ON edges (b);

The problem is I keep getting this error:
Code:
Msg 1785, Level 16, State 0, Line 8
Introducing FOREIGN KEY constraint 'FK__edges__b__628FA481' on table 'edges' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Msg 1750, Level 16, State 0, Line 8
Could not create constraint. See previous errors.

I am not sure what I am doing wrong, just need a little help.

Thanks
Golgi

-How important does a person have to be before they are considered assassinated instead of just murdered?
Congratulations!
 
get rid of the cascade commands

--------------------
Procrastinate Now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top