* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Download Worksheets52-56
Survey
Document related concepts
Transcript
.. .. .. .. . Data Base: an introduction What is a database A database is a collection of logically related data designed to meet the information needs of one or more users. The term “database” in English is related to any archive of information, also in paper form: for example, the cards for the different books in a library or an address book of clients are databases. A database on a computer, therefore, is basically a file of data that represents a certain situation, a certain organization or a given process and which contains sets of related information . The use of files of data on a computer allows you to update and search through the information much more easily than with a paper medium. We can think of a computer database as a filing cabinet where the drawers are called tables, the cards are called records and the headings on the cards are called fields. The data contained in the fields of a record (let’s take the example of a collection of books), can be of a textual nature (text), like the author's name, the author's surname, the title of the book or the place of publication, or numerical (numbers) like, for example, the number of pages. Here is an example concerning how to organize your books in a table: Fields Record Name Surname Title Printed in number 1 Number date of pages Paola Capriolo Una di Milano 236 2001 record loro TABLE 2 Alberto Moravia La noia Roma 125 1976 3 Cesare Pavese La luna e i Torino 177 1965 Falò The advantages of storing data inside records instead of on paper sheets are numerous: for example, you don’t need a cabinet and folders full of paper; but the main advantage is that on a computer the data can be visualized and ordered according to your present needs, it is not necessary to prepare multiple files with an index by author, by subject and so on; it is possible to order the data, do searches and quickly retrieve the desired information even when using more than one search criteria (for example, not only all the books printed in 2001 but all the books printed in 2001 that have more than 200 pages and that contain the word "Sky" in the title). The programs (applications) that allow you to create files of data, to update and modify them and to quickly retrieve the desired information with many different search keys are called Data Base Management Systems (DBMS). Access the program that will be used during this course, is a DBMS. EuNIC-ENG ITD-CNR/Centro Atene Worksheet 52 .. .. .. .. . Microsoft Access: an overview What is MS Access? Microsoft Access is a Database Management System or rather a specific program to create and manage databases. It is included in the Office Suite, which also includes Word and Excel and uses the same graphic interface. The purpose of Access is to create and manage data files: with its commands you can create tables, forms for the addition of data, you can order data inside the tables, you can rearrange and do searches on one or more tables and print the whole content of tables or the results of your searches. MS Access objects In Access we have six different kinds of objects: Objects Functions Tables to store data Queries to ask questions of the data Forms input and display data easily Reports to show data contained in tables and queries in a suitable format Macros to automatize some repetitive operations that can be done on the data Modules to make particularly complex operations that you cannot manage with the macros For the creation and management of a simple database only a small part of the functions and objects available in Access is necessary. The fundamental functions are those needed to create a new table with relative fields, to insert the data or to modify the existing data, to order them according to different criteria, to do a search (query) of the data in relation to specific criteria. EuNIC-ENG ITD-CNR/Centro Atene Worksheet 53 .. .. .. .. . MS Access: how to create a table Tables A table is a data set relating to a specific subject (for example it can contain data about a collection of books, about the products sold by a company, etc.). A database is generally made of different related tables (for example, one table for the products sold, one for the clients, one for the orders, etc.). In any case, the table is the main element of a database. The data in an Access table are divided into columns (fields) that correspond to a certain category of information (for example, the fields "name", "telephone" or "address") and lines (records) that correspond to the data set of a single element of the table (for example, the name, telephone and address of a specific person). How to create a new Table When you open MS Access you see a table like this: If you want to create a new database, in the New area of the Task Panel choose Blank Database MS Access asks you where do you want to save the new database (the extension will be mdb) Now you have three ways to create a new table: Create a table in Design view, where you can add fields, define how each field appears or handles data, and create a primary key. Use the Table Wizard to choose the fields for your table from a variety of predefined tables such as business contacts, household inventory, or medical records. Enter data directly into a blank datasheet. When you save the new datasheet, Microsoft Access will analyze your data and automatically assign the appropriate data type and format for each field. Here you can see a table created by entering data directly. Every field can have a different kind of data such as text, numbers, dates, etc. When you add your data the application automatically recognizes the type of data. When you have saved the table, you can open it and modify its structure at any time. EuNIC-ENG ITD-CNR/Centro Atene Worksheet 54 .. .. .. .. . MS Access: open a table, filter and sort data How to open an existing table In the Database window, click on “Tables” under Objects. Click the table that you want to open and choose one of the following: Open the table in Design view, which shows the design of the table. In Design view you can modify the design of an existing table. To do this, click “Design” on the Database window toolbar. Open the table in Datasheet view, which displays data in a row-and-column format. In Datasheet view you can edit fields, add and delete data and search for data. To do this, click on “Open” on the Database window toolbar. For example, with a double click on the “Employ” table you will see a datasheet like the one below. Sort Ascending, Sort Descending Sort the data in a table Very often, when you work with data you need to sort them. To do this, first you have to select the column that you want to sort, then you have two possibilities: select “Sort Ascending” (or “Sort Descending”) from the Records menu; click on the buttons as shown in the picture. How to filter data in a datasheet Filter buttons Filter By Selection and Filter By Form are two different ways to filter records in a form or a datasheet. If you can easily find and select the value that you want the filtered records to contain, use “Filter By Selection” in the Records, Filter menu. To filter by selection, select a field or a part of a field in a datasheet or form, and then click “Filter By Selection”. If you want to choose the values that you are searching for from a list, without scrolling through all the records, or if you want to specify multiple criteria at once, use “Filter By Form” in Records Filter menu; it displays the Filter by Form window, which is a blank version of the active form or datasheet, so you can filter data. EuNIC-ENG ITD-CNR/Centro Atene Worksheet 55 .. .. .. .. . MS ACCESS: queries In addition to filter and sort data, you can also use a Query to extract records from a table. What is a Query? You use queries to view, change, and analyze data in different ways. You can also use them as a source of records for forms, reports, and data access pages. There are several types of queries in Microsoft Access. To create a query, first you have to know exactly what you need (for example you have a library and you want to extract all the books printed in 2001); then you must define the criteria (in the example, the criteria in the field "Year of edition" will be "=2001", or ">2000 And <2002") and finally save and run the query to visualize the result. How to create a Query In the Database window, click on “Queries” under Objects and do one of the following: create a query in Design view; in this way you create a query by specifying the input tables, field names, filters and sorting or grouping properties; create a query by using wizard, in this way the wizard asks you questions and creates a query based on your answers. To create a query you have to plan what you want to visualize and the criteria that you need. To get a better idea of queries let’s look at the structure of a query that allows you to visualize all the books printed in 2001: Table added Query structure Field selected Table selected Show or hide a field Selection criteria What you see in the previous form corresponds to a SQL (Structured Query Language) instruction. SQL is the standard language that you use to query, update and manage relational databases such as MS Access. From a conceptual point of view, to plan a query means that you have to turn a question into a series of criteria that can answer your question. EuNIC-ENG ITD-CNR/Centro Atene Worksheet 56