issue67:tutoriel_-_libreoffice_p._20
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue67:tutoriel_-_libreoffice_p._20 [2012/12/08 17:17] – créée andre_domenech | issue67:tutoriel_-_libreoffice_p._20 [2013/01/18 16:38] (Version actuelle) – [3] auntiee | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ===== 1 ===== | ||
+ | ** | ||
Databases are used to store information about objects or data. In the previous tutorial, we mapped out how our books database would look. We designed tables for our data, and defined relationships between those tables. Now, we will put our planning into action by actually creating the database file, adding the tables, and creating the relationships. | Databases are used to store information about objects or data. In the previous tutorial, we mapped out how our books database would look. We designed tables for our data, and defined relationships between those tables. Now, we will put our planning into action by actually creating the database file, adding the tables, and creating the relationships. | ||
Ligne 6: | Ligne 8: | ||
To start the database wizard, select Database from the LibreOffice Home screen or File > New > Database. The first screen of the database wizard lets us choose whether we want to open an existing database or create a new one. Select Create a New Database, and click Next. | To start the database wizard, select Database from the LibreOffice Home screen or File > New > Database. The first screen of the database wizard lets us choose whether we want to open an existing database or create a new one. Select Create a New Database, and click Next. | ||
+ | ** | ||
+ | Les bases de données sont utilisées pour stocker des informations sur des objets ou des données. Dans le tutoriel précédent, | ||
+ | |||
+ | Création du fichier de base de données | ||
+ | |||
+ | Comme je l'ai mentionné précédemment, | ||
+ | |||
+ | Pour lancer l' | ||
+ | |||
+ | ** | ||
The second screen of the wizard asks us whether we want to register the database and what we want to do once the database has been created. Registering a database in LibreOffice makes it available in all our documents. We won't need this for our database, so select No – do not register the database. Check Open the Database for Editing, and click Finish. LibreOffice will open a file dialog to define a location and name for the database. I simply named the file: books | The second screen of the wizard asks us whether we want to register the database and what we want to do once the database has been created. Registering a database in LibreOffice makes it available in all our documents. We won't need this for our database, so select No – do not register the database. Check Open the Database for Editing, and click Finish. LibreOffice will open a file dialog to define a location and name for the database. I simply named the file: books | ||
Once you have a name and location for the database file, the main Base screen opens. Down the left side, you have the different pieces which can make up a database file. The top right gives you access to the different actions you can take for each part, and the lower right shows the objects already created. | Once you have a name and location for the database file, the main Base screen opens. Down the left side, you have the different pieces which can make up a database file. The top right gives you access to the different actions you can take for each part, and the lower right shows the objects already created. | ||
+ | ** | ||
+ | |||
+ | Le deuxième écran de l' | ||
+ | |||
+ | Une fois que vous avez un nom et un emplacement pour le fichier de base de données, l' | ||
+ | ===== 2 ===== | ||
+ | ** | ||
Field Types | Field Types | ||
Ligne 22: | Ligne 41: | ||
For our purposes, we will use Integer and VarChar. | For our purposes, we will use Integer and VarChar. | ||
+ | ** | ||
+ | Types de champs | ||
+ | |||
+ | Avant de créer notre premier tableau, nous devons discuter de quelques-uns des types les plus courants de champs de base de données. Lorsque vous sélectionnez un type pour un champ, on vous présente de nombreuses options pour ce type. Beaucoup de types sont identiques et sont là pour des raisons de compatibilité. Les types les plus courants sont les suivants : | ||
+ | |||
+ | Integer(Entier) : un nombre entier, par exemple 123 | ||
+ | VarChar : une chaîne de caractères de longueur variable. Vous allez définir la longueur maximale de la VarChar. | ||
+ | Date : une valeur de date, bien sûr, par exemple 15/10/2012 (le format exact spécifique à votre pays) | ||
+ | Temps : une valeur de temps, telles que 09:15:25 | ||
+ | Decimal : un nombre réel comprenant la partie entière et la partie fractionnaire, | ||
+ | |||
+ | Pour nos besoins, nous allons utiliser Integer et VarChar. | ||
+ | |||
+ | ** | ||
Creating the Tables | Creating the Tables | ||
Ligne 28: | Ligne 61: | ||
We will start with the Books table. Select Tables from the Database pane on the left. In the Tasks pane, click on Create Table in Design View... to open the Design View dialog. Across the top you have labels for each of the elements of a field: Field Name, Field Type, and Description. The Description is optional but is useful for making notes about how a field is used. At the bottom, we see the Field Properties. This section will change according to the type of field we select. | We will start with the Books table. Select Tables from the Database pane on the left. In the Tasks pane, click on Create Table in Design View... to open the Design View dialog. Across the top you have labels for each of the elements of a field: Field Name, Field Type, and Description. The Description is optional but is useful for making notes about how a field is used. At the bottom, we see the Field Properties. This section will change according to the type of field we select. | ||
+ | ** | ||
+ | Création des tables | ||
+ | |||
+ | Base a trois façons de créer des tables : grâce à un assistant de table, par la vue de conception et par des instructions SQL. L' | ||
+ | |||
+ | Nous allons commencer avec la table Books. Cliquez sur Tables dans le volet Database à gauche. Dans le volet Tasks, cliquez sur Create Table in Design View... | ||
+ | |||
+ | ===== 3 ===== | ||
+ | ** | ||
In the first field, enter the name BookID. From the dropdown box in Field Type, select Integer. Adding a description is up to you. Under the field properties, change AutoValue to Yes. This will place a key icon in the box beside the field record showing it is the primary (or key) index. In the second row, type Title for the name. Give this one a type VarChar. Again, a description is up to you. In the field properties, leave the length at 100, the default for VarChar. The third field is Published with a type of VarChar. Change the length in the field properties to 12. I chose VarChar rather than date because we just want the year, and if the publishing date of a book is unknown, I can enter just “Unknown”. Click on the save icon, and Base prompts you for a table name. Enter Books. | In the first field, enter the name BookID. From the dropdown box in Field Type, select Integer. Adding a description is up to you. Under the field properties, change AutoValue to Yes. This will place a key icon in the box beside the field record showing it is the primary (or key) index. In the second row, type Title for the name. Give this one a type VarChar. Again, a description is up to you. In the field properties, leave the length at 100, the default for VarChar. The third field is Published with a type of VarChar. Change the length in the field properties to 12. I chose VarChar rather than date because we just want the year, and if the publishing date of a book is unknown, I can enter just “Unknown”. Click on the save icon, and Base prompts you for a table name. Enter Books. | ||
Our tables for Authors and Media are created in much the same way. For Authors, create two fields: AuthorID, integer (AutoValue Yes); and Name, VarChar (length 50). For Media, MediaID, integer (AutoValue Yes); and Type, VarChar (length 25). | Our tables for Authors and Media are created in much the same way. For Authors, create two fields: AuthorID, integer (AutoValue Yes); and Name, VarChar (length 50). For Media, MediaID, integer (AutoValue Yes); and Type, VarChar (length 25). | ||
+ | ** | ||
+ | Dans le premier champ, entrez le nom BookID. Dans la boîte déroulante du Type de champ, cliquez sur Integer. À vous de choisir d' | ||
+ | |||
+ | Nos tables pour les auteurs et les médias sont créées à peu près de la même manière. Pour Authors (les auteurs), créez deux champs : AuthorID, integer (AutoValue Yes); et Name, VarChar (longueur 50). Pour Media, MediaID, integer (AutoValue Yes) et Pour Type, VarChar (longueur 25). | ||
+ | |||
+ | ** | ||
Our two foreign key tables need a little different treatment. In BooksAuthors, | Our two foreign key tables need a little different treatment. In BooksAuthors, | ||
+ | ** | ||
+ | |||
+ | Nos deux tables de clés étrangères nécessitent un traitement un peu différent. Dans BooksAuthors, | ||
+ | |||
+ | ** | ||
Create Relationships | Create Relationships | ||
Ligne 43: | Ligne 96: | ||
With our tables and relationships created, we are ready to begin work on creating forms for data input. In our next How-To, we will create the forms for data entry. Everything will come together to create a usable data entry system. | With our tables and relationships created, we are ready to begin work on creating forms for data input. In our next How-To, we will create the forms for data entry. Everything will come together to create a usable data entry system. | ||
+ | ** | ||
+ | |||
+ | Créer des relations | ||
+ | |||
+ | Une fois que nous avons défini toutes nos tables, nous pouvons créer les relations qui lient tout ensemble. Nous allons créer des relations entre nos trois principaux tableaux et nos tables de clés étrangères. La direction dans laquelle vous faites glisser les champs est importante, donc attention à la façon dont vous le faites. | ||
+ | |||
+ | Pour lancer la boîte de dialogue de définition de relation (Relation Design), allez dans Tools > Relationships. Une liste de tables apparaît. Choisissez une table et cliquez sur Add pour ajouter la table dans Relation Design. Ajoutez les tables dans l' | ||
+ | |||
+ | Faites glisser le champ BookID de Books vers BookID de BooksAuthors. Une boîte de dialogue Relations s' | ||
+ | |||
+ | Avec nos tables et les relations créées, nous sommes prêts à commencer notre travail sur la création de formulaires de saisie de données. Dans notre prochain tutoriel, nous allons créer les formulaires de saisie de données. L' | ||
+ |
issue67/tutoriel_-_libreoffice_p._20.1354983420.txt.gz · Dernière modification : 2012/12/08 17:17 de andre_domenech