[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

need to understand the relationship amoung tables in a database.

Posted on 2008-01-28
9
Medium Priority
?
464 Views
Last Modified: 2010-04-05
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?
0
Comment
Question by:QurbanDurrani
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 20766020
?? 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
 
LVL 6

Expert Comment

by:FactorB
ID: 20766248
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
 
LVL 21

Assisted Solution

by:developmentguru
developmentguru earned 400 total points
ID: 20767637
 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 13

Accepted Solution

by:
rfwoolf earned 800 total points
ID: 20768966
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
 

Author Comment

by:QurbanDurrani
ID: 20779236
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
 
LVL 27

Assisted Solution

by:kretzschmar
kretzschmar earned 400 total points
ID: 20781170
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
 

Author Comment

by:QurbanDurrani
ID: 20800394
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
 
LVL 6

Assisted Solution

by:FactorB
FactorB earned 400 total points
ID: 20803281
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
 

Author Comment

by:QurbanDurrani
ID: 20878688
Thanks guys for the very informative answers.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question