0% found this document useful (0 votes)
21 views14 pages

ITFPlus (FC0 U61) Module2 - Unit4 LE10

Uploaded by

Patano Carl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
21 views14 pages

ITFPlus (FC0 U61) Module2 - Unit4 LE10

Uploaded by

Patano Carl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 14
“ O = Lab 10/ Creating and Using a Database In this lab, you will use the database application bundled with Apache Open Office to create a database, use a form to input data, and build a query to select and view records, Exercise 1/ Installing Apache Open Office In this exercise, you will install Apache Open Office to make its database application available. You will also need to install the Java Runtime Environment in order to use the database features of Open Office. v This lab involves downloading and installing programs from third- party websites. The authors and publisher believe the websites and programs to be reputable and pose no risk to your computer or personal information but cannot be held responsible for any loss or damage that may occur as a result of following the steps in this lab. If you have any concems we recommend that you do NOT proceed. 1) Ifnecessary, start your computer and sign in. 2) Open a browser and navigate to java,com/en/download/windows offline.isp 3) Ifnecessary, accept the use of cookies by the site. On the main page, click the Agree and Start Free Download button. 4) Inthe prompt at the bottom of the window, click Save. When download is complete, in the prompt, click Run. Do wecapatons pm a eee rN) seem Download Java for Windows Ofine Installation Sssessuas _eonmace renUss 38 pn 959) ‘Ene ‘wat do you wanted wie Bi nines SEBO IS sor in Swe From seed com Downloading the Java Run Time Environment offine installer. Pege 190 5) Inthe User Account Control window, read the warning but click Yes. Using Databases 6) Ifnecessary, on the taskbar, click the Java icor In the Java Setup wizard, click Install. At the license terms warning prompt, click OK. 7) When prompted, click Close. Having installed the Java Runtime Environment, you can now download and install Open Office. 8) In the browser, navigate to openoffice.org/download 9) Under the Download Apache OpenOffice heading, select Windows (EXE) and English (US), then click Download full installation. Qe oo | 4 Ocketonce mrense 2s | eee RT —EI ne OpenOffice 4.1.5 releas ae eae Oriana: Oommen Anema oa Downloading the Apache Open Office Windows executable. 10) If necessary, accept the use of cookies by the SourceForge site. In the prompt at the bottom of the window, click Save. 41) When download is complete, in the prompt, click Run. g Windows does not trust the installer. In this case you have to trust the site that you downloaded the file from (sourceforge.net). You can find out more about how to verify the installer by browsing Open Office's FAQs fy). 12) In the User Account Control window, read the warning but click Yes. 13) In the OpenOffice Setup wizard, click Next 14) On the Choose Install Location page, click Install. 15) On the Welcome to the Installation Wizard for OpenOffice page, click Next, Pege 191 Module 2/ Unit 4 16) On the Customer Information page, click Next, 17) On the Setup Type page, click Custom and then click Next 18) Review the components. Click Next. 19) On the File Type page, clear all check boxes and then click Next. This step is very important if you already have Microsoft Office installed. 20) On the Ready to Install the Program page, click Install. 21) When prompted, click Finish. 22) Close the browser. 23) On the desktop, double-click the OpenOffice icon. 24) On the Welcome page, click Next. 25) Complete the User name information and then click Finish. 26) From the Tools menu, select Options. In the O| ns dialog, select Java After a few seconds, the dialog should update to show a path to the Java runtime environment. ator Sc Tlbea a nrtneenscrat 1 ia nomen ey cs can coger eet Be cot || ue |e Veving te Jove path, 27) Click OK. 28) Close the Open Office window, Pege 192 Exercise 2/ Creating a New Database In this exercise, you will create a new database and create database tables. 1) On the desktop, double-click the OpenOffice icon. 2) In Open Office, click Database. 3) Inthe Database Wizard, on the Select database tab, click Create a new database and then click Next. 4) On the Save and proceed tab, click Finish 5) Inthe Save As window, in the navigation pane, click Documents. 6) Inthe File name box, type CompTIA and then click Save. 7) Inthe open database window, click Tables and then click Create Table in Design View. As a first step, we will create a primary key for the table. As the primary key must always be unique, it is a good idea to use an automatically generated number for this field 8) Inthe new table window, in the Field Name column, type CustomerID 9) Inthe Field Type column, select Integer [INTEGER ], and in the Description column, type Primary key for the Customer table 10) In the lower panel, from the AutoValue box, select Yes. 11) Click back in the field name area. (© Comprised: Toil -Opencice Bee Table Design — ox Ble £6 Vien Teele Window Help aie ae | Fediame | Faaivee | Decision [Cuore megeTINTEGER) —__Primaaya forte Customer ole = Fld ropeiee Auotohe Wve Length re | Foumatexamle Creating a field to use as the primary key. The database engine automatically picks this field to use as a primary key. A key icon appears in the row selector in the far left (the grey box) to show this Poge 193 Module 2/ Unit 4 This sets constraints for the field. Note that the length constraint sets a maximum length, so the user can enter fewer characters if needed. If we used a fixed length CHAR field data type, the same number of characters would have to be input each time—obviously that would not be suitable for a company name. 15) Add an address field to the table with the following properties: © Field name: address © Field type: Text [ VARCHAR ] © Description: Enter the address © Required: No © Length: 50 16) Add a telephone field to the table with the following properties: © Field name: Telephone ©. Field type: Number [ NUMERIC ] © Description: Enter the phone number with no spaces © Required: No © Length: 10 Your table design should now look like this: ‘© CompTiA.odb : Table! - OpenOffice Bese: Table Design, - oa x fle Eat View Tooke Winsow Hele aia Hog TedNome [ Redtype Desatstion [eset ntgerINTEGER] Pray ay forene Customertabe = Name Tex[VARCHAR] [Ente the company name Jacdess ——TenIVARCHAR] ——_Erterthe adres freccrons —__NumoerC NUMERIC] Erte the shone numer ih ne scke Fie Properties, ty required Lenaes Decimal paces eau value [ Format example | Completing the table design 17) On the toolbar, click Save. Page 194 18) In the Save As box, type the name Customer and click OK. Using Databases 19) Close the Customer table. In the database window, click Create Table in Design View. 20) In the new table window, in the Field Name column, type Contact ID 21) In the Field Type column, select Integer [ INTEGER ], and in the Description column, type Primary key for the Contact table 22) In the lower panel, from the AutoValue box, select Yes. 23) Click back in the field name area. The field is set as a primary key automatically. As each contact will be connected with an associated company record, we now need to add the CustomerlD field as a foreign key in the Contact table. 24) In the Field Name column, type Customer 25) In the Field Type column, select Integer [ INTEGER ], and in the Description column, type Select a customer record 26) In the lower panel, from the Entry required box, select Yes. 27) Add a first name field to the table with the following properties: © Field name: FirstName © Field type: Text [ VARCHAR ] © Required: Yes © Length: 25 28) Add a surname field to the table with the following properties: © Field name: Surname © Field type: Text [ VARCHAR ] © Required: Yes © Length: 25 29) Click Save. 30) In the Save As window, in the Table Name box, type Contact and click OK. 31) Close the table window. 32) From the Tools menu, select Relationships. 33) In the Add Tables dialog, with Customer selected, click Add then select Contact and click Add. Click Close. Page 195 Module 2/ unit 4 Page 196 34) Drag the CustomerID field from the Customer table over the Customer field in the Contact table, © CompliAcoab : CompllA- Openbifie Base Reltion Design - o x Ble Ede View Inset Toole Window Help Baoc|se i customer oan Name Address Telephone conser (Beata Fistharne surame Creating a relationship between two tables. Note the symbols on the join line. The customer table side is shown with a "1" while the contact side is labelled "n.” This represents a one-to-many relationship. Each single record in the Customer table can have many related records in the Contact table. This is the most common type of relation 35) Close the Table Relationships window. Click Yes to save when prompted. 36) On the menu bar, click Save to save the database tables. Exercise 3 / Creating a Form and Entering Data In this exercise, you will populate the database with sample records using a simple form 1) With the CompTIA database open, click the Forms button. 2) inthe Tasks list, click Use Wizard to Create Form, 3) Inthe Form Wizard, in the Tables or queries list, select Table: Customer. 4) Inthe Available fields list, select Name, Address, and Telephone then click > Using Databases Stews Select the ted of your form Tbleserqueies Setup saber [Tbe cuzemer |] 3 Ad afr ld vate ls Fiesin the fm 4 Name S.Aerange contle SP] sares Se dat ent peptone Tbpply stiles I sername | Binary fi are alway sted and selectable from the eft i, pons they are mtervetd 9 mages, Hep check Net> Ein ‘Ganeel Creating a form withthe wizard. As the ID field is automatically generated for each new record, it does not need to be added to the form 5) Click Next. 6) Check the Add Subform box and the Subform based on existing relation option button. Select Contact. Fm Wiad x jes SS~S~*~*i emery eee cece |. Field selection, add subform @ Sibi en on eitngraion a Which elation doyou wontto [T= 4 cetinetal ae S.Armge conte 6 Se dt ty hops {© Sion bese onsmanuleelecon ofl setae ie ser t ere ereie eee ee eee datos | < % ABP NBIRY 7 Contact | Customer | FirstName | Sumame ot 0 Dave Matin fi lo Sue Smith 2 1 ‘andy Waren B 1 lames Pengelly 7 | AutoFielt> Reco [i ee TA Values added to the Contact table foreign key Customer field These values are added automatically by the database engine because of the relationship you defined between the tables and between the form and subform, 24) Close the Contact table. Page 198 Module 2/ unit 4 Page 200, ry Wiad x Exercise 4/ Working with Queries In this exercise, you will use a query to extract data and display it using a report. 1) With the CompTIA database open, click the Queries button, 2) Click Use Wizard to Create Query. 3) Inthe Query Wizard window, from the Tables list, select Table: Customer. 4) Select all fields except CustomerID and then click >. 5) From the Tables list, click Table: Contact. 6) Select the FirstName and Surname fields then click >, cial ‘tens ‘Select the feis (clumns) for your query Tables 2.5ertng rcer ble: Contact 2. Seacch conditions Avalablefitde Fields inthe Quay 4 Dede orem: {contact (Cusemerfleme 5 Grouping i ntomer Ades Etiaiging cones \cuszme-Telephone [Contact Firs\ame Contact Surname alaces 2.Qveniew = Defining fields to show in the query. 7) Click Next, 8) On the Sorting order tab, in the Sort by list, select Customer.Name and in the Then by list, select Contact.Surname. 9) Click Next. 10) With Match all of the following selected, from the Fields list box, select, Contact.FirstName. From the Condition box, select is not equal to, and in the Value box, type Dave 11) Click Finish. What is wrong with the query results? Bony, file Edi View Jpseit Tools Window Help MHB- fe Re Name | Address [ Telephone | FistName | Suname | usiomer - CompTIA - Opendfice Bese Table Data View - a x Using Datsbsses ET Wain R0000000222 —Jemes —_—_[Pengely Grommet 21 in R 8330002222 Sue ‘smith [rornmet 21 Min Re 8880002222 [Andy Waren Widget 123 Addiess 999000TTT1 [eres (Pengely Widget — 103 Address 990007TT1 [Sue Smith [Widget 123 Addiess 9990001111. Andy ——_—_Wawen iecoral = = Pn All of these people seem to have more than one jobi To fix the output, we need to re-state the join (relationship) between the tables in the query builder. 12) Close the query window. In the database window, right-click Query_Customer and select Edit 13) Drag the CustomerlD field from the Customer table over the Customer field in the Contact table. ‘© CompTid.odb : Query Customer - OpenOffice Base: Query Desian Ble Eat View neat Tele Window Help a2 oe se) ef sik Cite sme esse Teephone Fil [Neme — [Bfaciress Telephone FitName Surname ‘alas [Nene ‘Adsress Telephone FistName _Sumame Table [customer Customer Customer Contact Contact, ‘ot Vb a a a a a a Fs ius 2 Dae or Setting the join in query design view. Page 201 Module 2/ unit 4 Page 202 14) Click the Save button then press F5, This runs the query within the builder interface, You should see that the join is now working properly and the query is returning one row per contact record rather than generating rows for each unique combination of customer and contact records. © Comprit.odb- Quer) Custemer- OpenOlfice Bae Cuery Design - a x le Edt Yew Inver Tools Window Helo Tame | Adaress | Telephone | Fistiame | Sumame [Widget — 123 des SB000TTTT — Sue Smith [iommet 321 ain Rc e280000222 nay Waren [Grommet 321 sin Re str00222 omer Pengely a Ce FrstNere Sumame T T a [ssi eiphone frame —_fsurame * Ais Addie Telephone [Pte Serame | a me | Sot [ | | Visible a a | @ a | @ a Function | I ition | I ‘Running the query. 15) Close the query window. In the database window, right-click Query_Customer and select Edit in SQL View. © Compt Add : Query Customer - OpenOifice Base: Query Design - o x Ble Ee Wow wan Toe Yofow Hp SP xaes om wie fix i ‘SQL statement underpinning the query. Everything you have done in the database GUI is using underlying SQL. Using Databases Note the features of this statemer © The SELECT statement chooses records for viewing (data manipulation). Itis followed by a list of column (field) names to use in the output. The AS keyword specifies an alias for each field. © The FROM keyword lists the data sources (Customer and Contacts). ©. The WHERE keyword states the join and the criteria excluding "Dave." 16) Close the SQL window. 17) Close Open Office, choosing to save changes when prompted Page 203

You might also like