Relational Databases

From: Bryan <btjedwards_at_hotmail.com>
Date: 24 Nov 2003 09:04:53 -0800
Message-ID: <e8a5a6b7.0311240904.691d01d4_at_posting.google.com>



Hi there, I think this is the correct place to post this but if not someone please direct me to where it should go. I'm pretty new to relational databases and i'm currently working on designing a database but i think i've found a potential problem. To keep the problem simple i've got 2 tables, computer and group and its a 1-to-many relationship ie 1 or more computers make up a group.

The computer table has these fileds (and more but keeping it simple) CID - primary key
CName - Text label
Router - integer
GID - Int (Identifies which group the computer is in)

And the group table is
GID - primary key
GroupName - text label
Router - Int

The router field is an integer pointer to a router table like the one below
RID - Int primary key (int pointers point to here) Router IP - IP address of router

Basically when the administrator of the database adds an entry to the computer table, they can specify a router for a computer(if the router exists in router table point to it, if not create new entry in router table and point to it). The int pointer goes in the router attribute of the computer table. If the administrator doesn't specify a router, the router entry in the computer table takes the default value specified in the group table( can get it because GID has to be specified in the computer table when making an entry)In the example below the router hasn't been specified for CID=1 but it belongs to GID=1 so the router value for the entry GID=1 (ie 4) is taken as the router value for CID=1

Computer table
CID CName Router GID
1 Sales1 (4) 1
Group Table
GID GroupName Router
1 Sales 4

The problem that if the router of GID is changed to 5, how do I make sure that this gets updated in CID=1. I think its something to do with storing redundant data but i don't know how to get around it. I could when i make a change to the router entry in the group table search the computer table for entries where GID=1 and change the router value to 5 but it could be that the administrator defined the router for CID=1 to be 4 and even though it belongs to GID=1 the router pointer should stay at 4. Also bear in mind that this problem is happening in many fields and not only 1, but i've kept it simple to hopefully make it easier to understand.
I hope i've explained this clearly, if not I'll try any explain what you don't understand Many thanks in anticipation Bryan Received on Mon Nov 24 2003 - 18:04:53 CET

Original text of this message