need to understand the relationship amoung tables in a database.

Hi Experts,
I am maintaining a Delphi7 application which workes with tables in a paradox datbase using BDE.
In order to make sure that my application does not violate the referential integrity of a database, my guess is that I need to understand the relationship amoung the tables in the database. Is this correct? and if yes, How do you achieve that in a paradox database?
QurbanDurraniAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kretzschmarCommented:
?? didn't understand the question

even in paradox you can define releationships between tables,
which are watched by the paradox-engine,
so you do not need to care about the relations within your delphi-app
(you may get an exception if you are about to avoid the defined relation)

so what is the question?

meikl ;-)

0
FactorBCommented:
Table relationships (database relationships) can be related in three ways:
One-to-One, One-to-Many and Many-to-Many.
I usualy write my answers but since there are many well documented pages about this topic, I am posting his link.

http://www.informit.com/articles/article.aspx?p=31475&seqNum=4

I hope it will guide you in right direction.
0
developmentguruPresidentCommented:
 Unfortunately the llinks between tables can be supported by the database engine (recommended), by the programmer (in situations where Paradox may not support the relation the way you want to), or be unenforced.  The only way to understand the relationships (speaking as a developer who has had to come into undocumented projects many, many times) is to examine the database first, then the code that uses it.  Does the company own a copy of Paradox?  If it does then you can use it to see what relationships have been set up from within Paradox.  If it does not then it is llikely that the database files were set up with a limited tool, or even with raw code.  If that is the case then it is likely that any referential integrity is being handled in the code.  If you are unable to find any referential integrity in the database or in the code then there likely is none.

  Sorry about the long answer.  The short version is this, you will have to look.  I hope that what I wrote gives you a plan of attack at least.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

rfwoolfCommented:
Firstly how are you editing the table definitions for your Paradox Tables? With Delphi 7 you should have a copy of Database Desktop, otherwise there are other tools, including the JEDI Database Desktop which you can download here: http://sourceforge.net/projects/jedidbd/ (although I still recommend the normal Database Desktop).
When you edit a table in DD, you can see if any dependancies on any field exist which will tell if  there are any referential integrity settings for a field.
But this only tells half the story because it's entirely possible that the developer took care of referential integrity from within the application (which is not the best-practise way to do it, but is not entirely uncommon to technically do both).

What kind of datasets are used in the application, for example TTable? You could have a master-detail relationship of two tables. In case you don't know, that's where you have two TTables (the one being the master, the other being the detail), and with the detail TTable you set the MasterTable setting in the object inspectior to the master table, and you set the KEY to a field which is common in both tables.
So in one example your Master Table could be your Customer's Table, and the detail table could be Customer's Orders, and you would link them via the field Customer ID (as the Key).
In this way you can have a Top DB Grid where the user selects a customer, and
a bottom DB Grid which shows all the orders for that customer.
If the user tries to delete a customer, you would add a BeforeDelete event to the customer (master) table that says
begin
  if MyDetailTable.RecordCount > 0 then
  begin
    showmessage('You cannot delete this customer while it has orders. Try deleting the orders first');
    abort;
  end;
end;;

In this way, not only have you maintained referential integrity, but you've also customised this for the user instead of getting a generic message back from the BDE saying something generic about referential integrity and confusing the user.

Hope that helps.

Otherwise just ask
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
QurbanDurraniAuthor Commented:
Thank you so much to all of you for your very informative answers, even though I did not state my question very clearly.
I use paradox and Database desktop. Is there a way in Database Desktop to find out the relationships amoung the tables in the database. For example if table1 is a master to table2 which is a master to table3 which is a master to table4 and table2 is also a master to table7. and so on. Is there a way in Database desktop to find out these relationships, other that just looking at all the table for hours and still miss some relationships.
Thanks again for all the help.
0
kretzschmarCommented:
you need Entity-Relation-Diagramm
don't know yet, if the database-Desktop is able for this
maybe there is a tool  able for this . . . somewhere

are the relations defined?
as far as i know Database desktop.has a two table dialog for defining a relation

meikl ;-)
0
QurbanDurraniAuthor Commented:
The relations do exist. Now if that is not the same as being defined, that how do I find out if they are defined?
How do I get the Entity-Relation-Diagramm?
Thanks
0
FactorBCommented:
Try Case Studio (citation: This software is for all developers, database designers and for all who want to create and maintain their database structures effectively), see if it is what you want.

http://www.casestudio.com/enu/products.aspx

Regards
B
0
QurbanDurraniAuthor Commented:
Thanks guys for the very informative answers.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.