Kexi/Handbook/Building Simple Databases/Designing Database Queries/da: Difference between revisions
(Importing a new version from external source) |
(Importing a new version from external source) |
||
Line 8: | Line 8: | ||
For at se, hvordan forespørgsler virker i praksis vil vi lave forespørgsel efter kontakter, som forenen data fra de to tabeller '''''Personer''''' og '''''Telefonnumre''''' (som blev designet [[Special:MyLanguage/Kexi/Handbook/Building Simple Databases/Designing Database Tables|her]] og fyldt med data [[Special:MyLanguage/Kexi/Handbook/Building Simple Databases/Entering Data Into Tables|her]]). | For at se, hvordan forespørgsler virker i praksis vil vi lave forespørgsel efter kontakter, som forenen data fra de to tabeller '''''Personer''''' og '''''Telefonnumre''''' (som blev designet [[Special:MyLanguage/Kexi/Handbook/Building Simple Databases/Designing Database Tables|her]] og fyldt med data [[Special:MyLanguage/Kexi/Handbook/Building Simple Databases/Entering Data Into Tables|her]]). | ||
# | # Lav en ny tom forespørgsel ved at klikke på <menuchoice>Forespørgsel</menuchoice> i værktøjslinjen; så dukker designvinduet op. Vinduet er delt i to dele: øverst vises forespørgslens relationer og nederst vises '''Forespørgselssøjlerne'''. | ||
# Select the table '''''Persons''''' in the drop down list '''Table:''' located at the top of the window and click the <menuchoice>Insert</menuchoice> button. A graphical representation of the table will appear in the relations area. Do the same for the '''''Phones''''' table to insert it too. | # Select the table '''''Persons''''' in the drop down list '''Table:''' located at the top of the window and click the <menuchoice>Insert</menuchoice> button. A graphical representation of the table will appear in the relations area. Do the same for the '''''Phones''''' table to insert it too. | ||
# Add query relationship using mouse drag & drop technique: click the field id in the table persons table, drag it and drop into the person field of the '''''phone''''' table. This will join both fields by creating a new relationship. | # Add query relationship using mouse drag & drop technique: click the field id in the table persons table, drag it and drop into the person field of the '''''phone''''' table. This will join both fields by creating a new relationship. |
Revision as of 06:24, 16 April 2012
Design af databaseforespørgsler
Det primære formål med en database er at lagre information og hjælpe med at udtrække den information du har brug for. Til forskel fra databaser skrevet ned på papir lader en Kexi-database dig specificere flere søgekriterier. Resultater findes hurtigere, selv med store datamængder. Dette er en af databasens stærke sider, men for at kunne lave effektive forespørgsler på din database skal du lære, hvordan du fortæller databasen, hvad du søger efter.
Med en databaseforespørgsel kan du begrænse data fra en tabel til at omfatte nogle forud definerede søjler og rækker, og du kan forene data fra forskellige tabeller.
For at se, hvordan forespørgsler virker i praksis vil vi lave forespørgsel efter kontakter, som forenen data fra de to tabeller Personer og Telefonnumre (som blev designet her og fyldt med data her).
- Lav en ny tom forespørgsel ved at klikke på i værktøjslinjen; så dukker designvinduet op. Vinduet er delt i to dele: øverst vises forespørgslens relationer og nederst vises Forespørgselssøjlerne.
- Select the table Persons in the drop down list Table: located at the top of the window and click the button. A graphical representation of the table will appear in the relations area. Do the same for the Phones table to insert it too.
- Add query relationship using mouse drag & drop technique: click the field id in the table persons table, drag it and drop into the person field of the phone table. This will join both fields by creating a new relationship.
- Double-click the name field in the Persons table, to add the field as a query column. In a similar way, add surname, street, house_number, city fields from the Persons table and phone from the Phones table.
- Query design is now ready for testing. Click the button on the toolbar, to switch from design to viewing the data provided as query results.
- Save the query design for later use by clicking the button on the toolbar. Because the query design has not been saved yet, you will be asked to specify a name for it. Enter Contacts text in the caption field and click the button.