Avatar billede Slettet bruger
01. juli 2005 - 14:55 Der er 8 kommentarer og
1 løsning

Hvorfor relationer

Jeg har efterhånden fået lavet en hel del databaser, men jeg bruger kun relationer i forespørgsler, ikke for selve tabellerne. Er der nogen grund til at lave om på den praksis?~)
Avatar billede terry Ekspert
01. juli 2005 - 15:04 #1
One of the advantages with relations is that it will be possible to use referential integrity.
http://www.ehow.com/how_13625_understand-referential-integrity.html
Avatar billede terry Ekspert
01. juli 2005 - 15:06 #2
Lets say you have a table containing postal code and another customers. You could have a customer which uses postal code 7100 (Vejle)
Now you can go into the postal code table and delete the record for Vejle. If you had use relationships and referential integrity you would not be allowed to.
Avatar billede terry Ekspert
01. juli 2005 - 15:09 #3
When you design your tables there is a field type (lookup wizard) this is actually a wizrad which makes the relationships for you. Then if you go in the Relationships window you will be able to see how the tables are relaed. You can then alter the relationship types by right clicking on the thin line.
Avatar billede Slettet bruger
04. juli 2005 - 08:28 #4
Ok I understand.

But what happens to the relations if you have to "bring in" a linked table to work on the db. Deleting the linked table and then importing it and vice versa?~)
Avatar billede terry Ekspert
04. juli 2005 - 08:56 #5
You should still be able to link tables which are linked with tables which are not. Whet do you mean by "Deleting the linked table and then importing it and vice versa?~)"? Do you mean actually replacing a linked table with a local table?

You can always remove a relationship and make it again when you have imported.

Lets say you have an Order/Order Detail relationship. If you used referential integrity and Cascade Deletes then by deleting a record in the Order table would also deleted related Order Detail records, without any extra code.

So there are a number of advantages using relationships.
Avatar billede Slettet bruger
04. juli 2005 - 12:48 #6
Sorry, I'm so slow with the reply but I got lots of projekts going.

It's because I have had problems developing with linked tables. It has slowed everything down (to the point of complete stops in some occassions), so therefore I import those linked tables, develop and then link to the backend again. If I had a lot of relations they would disappear when I delete the tables. So, actually the question is: Do the relations come back automatically if you delete a table and import it again (I think I can guess the answer!~)

As it is from my viewpoint I don't gain enough by working with the relations, so.... I will properly continiue as is!~)
Avatar billede terry Ekspert
04. juli 2005 - 13:01 #7
You don NOT have to have relationships, but indexing your fields is important too. Performance problems could be a slow network connection too.
Avatar billede Slettet bruger
04. juli 2005 - 14:28 #8
Thanks for your input, Terry!~)
Avatar billede terry Ekspert
04. juli 2005 - 14:36 #9
selv tak
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester