Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old May 31st, 2005, 9:53 AM   #1
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
Relational Database tables[solved]

Am i right in thinking that a relation database is only in the mind...

I mean i know you can link table using sql commands but is there an sql command to create a relationship between 2 tables, like ACESS does so that i can cascade delete on things?

-----------------------------------

edit worked it out myself dont worry

if anyone cares here is a lot of sql

CREATE TABLE site
(
ID INT NOT NULL,
Name VARCHAR(30) NOT NULL,
CONSTRAINT spk1 PRIMARY KEY (ID)
);

CREATE TABLE area
(
ID INT NOT NULL,
siteID INT NOT NULL,
Name VARCHAR(20) NOT NULL,
CONSTRAINT apk1 PRIMARY KEY (ID),
FOREIGN KEY (siteID) REFERENCES site(ID) ON DELETE CASCADE
);





CREATE TABLE cell
(
ID INT NOT NULL,
areaID INT NOT NULL,
Name VARCHAR(20) NOT NULL,
CONSTRAINT cpk1 PRIMARY KEY (ID),
FOREIGN KEY (areaID) REFERENCES area(ID) ON DELETE CASCADE
);

CREATE TABLE rack
(
ID INT NOT NULL,
cellID INT NOT NULL,
Name VARCHAR(20) NOT NULL,
CONSTRAINT rpk1 PRIMARY KEY (ID),
FOREIGN KEY (cellID) REFERENCES cell(ID) ON DELETE CASCADE
);

CREATE TABLE shelf
(
ID INT NOT NULL,
rackID INT NOT NULL,
Name VARCHAR(20) NOT NULL,
CONSTRAINT spk1 PRIMARY KEY(ID),
FOREIGN KEY (rackID) REFERENCES rack(ID) ON DELETE CASCADE
);

CREATE TABLE bin
(
ID INT NOT NULL,
shelfID INT NOT NULL,
Name VARCHAR(20) NOT NULL,
CONSTRAINT bpk1 PRIMARY KEY(ID),
FOREIGN KEY (shelfID) REFERENCES shelf(ID) ON DELETE CASCADE
);


----------------------

it was setting up the foreign key references that i was trying to do.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein

Last edited by Berto; May 31st, 2005 at 10:02 AM.
Berto is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:11 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC