Creating databases in Microsoft Access. How to create a database in MySQL

From the author: We live in the age of information, so people have developed quite convenient technologies for storing it. Today I will show you how to create a database on hosting and why it is even necessary.

I already think that you yourself understand what a database is needed for - to store data. When installing any engine manually, you will be required to create it. Well, okay, but how to do this? There are at least 2 simple ways to do this.

Creating a database through the server control panel

Perhaps this is the simplest option. Any hosting provides you with CPanel or any other panel to manage your websites. There you can find the “Databases” item, where you can visually create a new database, a new user, and then link it to the database. It is not necessary to create a user if it has already been created. All rights must be set if this is an administrator profile.

Creating a database on hosting using the PhpMyAdmin utility

In fact, there are many utilities for working with MySQL and other databases, but this one is the most common. Creating a database in phpmyadmin is also easy.

Click Databases and a list of databases will appear, as well as the ability to add a new one by entering its name. After creation, you will also need to add or create a new user for the database. To do this, edit the privileges of the new database.

As you can see, here you can see which users already have access to the database, as well as add a new one.

Transferring the database and uploading it to another hosting

First of all, I want to point out that your database is practically the most important and valuable thing you have. After all, these are all posts, pages, reviews, comments and everything else that may be on the site. And if this disappears, then it is a complete disaster for you. Therefore, first of all, make sure that the database is constantly backed up, preferably in several places. This way you will protect yourself.

If anything, the database dump extension is sql. That is, you download the database dump to your computer. Well, how do you actually load the database? It is best to use the same utility for this – PhpMyAdmin. Let's go into it. There is an Import button, but let's not touch it for now. First you will need to create a new database or delete all tables in the old one.

In short, you need a clean, bare DB. We select it and import our dump into it. If everything went well, you will see tables appearing in the database, and over time you will be convinced of the correctness of your actions when you go to the site for which all these manipulations were performed.

Interestingly, all this can be done through the server control panel. There you can also download database dumps.

How to link to the site?

The connection occurs automatically during the installation of the engine. There you specify the database name, username and password to access the database, server (almost always localhost) and table prefix. But if suddenly something changes during work, then the data will need to be changed.

For example, you changed the database name or deleted a user and assigned another. Accordingly, if you do not change the necessary parameters, when you access the site, a connection error with the database will be displayed and you will not even be able to talk about any operation of the resource.

In this regard, IMMEDIATELY after making such changes, you need to change the corresponding parameters. If you have a WordPress engine, then they are stored in the wp-config. In particular, there are the following constants:

DB_NAME – database name. DB_USER – username DB_PASSWORD – password

And also the variable: $table_prefix;

Accordingly, you must ensure that the values ​​of these parameters are correct. There shouldn't be any errors. In other engines such settings are also present.

Can there be several databases on hosting?

Of course, absolutely no problem. 1 database per site (in most cases). If you have several sites, then there will be several databases. A large resource may have several databases for different sections. For example, if you decide to install a forum on your site, you can create your own database for it.

In general, all these are the basics of working with a database, if suddenly you want to learn how to work with MySQL (and this is the language with which you work with databases) from A to Z, then we have a wonderful one for you, lasting more than 20 hours in which you can master this technology once and for all.

Modern trends and approaches in web development

Learn the algorithm for rapid growth from scratch in website building

Creating databases and using them in your web pages is a fairly powerful tool that solves many web development problems. With this article I want to open a series of lessons that will help you work with MySQL databases.

This article will focus on installing MySQL on your computer and basic operations related to creating databases, creating tables, setting privileges, deleting a database. And in subsequent lessons we will look at the interaction of PHP program code with the database. We will learn how to insert data into the database by filling out forms, extract the necessary data to the right place on the page, change and delete data located in the database.

You may have a question: is it really necessary to install MySQL on your local computer, if now every hosting provider provides the opportunity to use MySQL database? This is true, but there are a number of reasons why I would advise you to install a MySQL database on your computer.

Firstly: You may not always be located where there is an Internet connection, and the code may well need to be debugged and tested at this very moment. You can work with a local database anywhere: on an airplane, on a train, in a country house, or simply when something happens to your Internet provider and you are left without the Internet.

Secondly: It’s usually rare that you can write code without any bugs or errors the first time. Agree that it is much better to first polish your code and test it on your machine than to post and correct the code on the Internet.

Third: installing MySQL database on your computer and working there with it, you will learn to navigate all the nuances and subtleties much better and faster, and you will understand MySQL much faster.

A very useful and convenient tool that allows you to create MySQL databases and work with them I am Denwer. It also allows you to test php code. If it is not already installed on your computer, be sure to install it. There is nothing complicated here. All you need to do is follow the link to the Denwer website and download Denver to your computer. On this same page you will find detailed instructions for installing Denver, which I see no reason to rewrite into this article.

After the successful installation of Denver (when you saw the inscription “Hurray, it’s working!”), let’s start working with the MySQL administrator page.

Login to the MySQL database administration page To access the database administration page, enter the following address in the command line of your browser: localhost/tools/phpmyadmin/. You should see something like this:


The left column contains the available databases (you will most likely have fewer of them than in the screenshot), in the central part the main settings (here you can change the language, type, encoding). The top tabs are designed for different tasks (we'll talk about them later).

Creating a MySQL Database

In order to create a new database, click on the top tab “Databases” and a list of all available MySQL databases will open in front of us in the central field. We need to create a new one. To do this, in the “Create a database” field, enter the name of the database to be created and click on the “Create” button.


After you click on the “Create” button, the database will be added to the list of databases in the left panel and in the central field. Now select a new database by clicking on its name.

Here you will be asked to create a table. Let's create a database table. To do this, fill in the “Name” and “Number of columns” fields and click OK.


After this, a page will open for you to fill in the fields of the new database table. Here, each field needs to be assigned a name, type of stored data, length (if required for this attribute) and for a field such as an identifier (id), you also need to specify an auto-increment and a primary key. It should look like the screenshot below.

A little about data types.

In my example, we encountered such data types for the base table as int and varchar.

Int– indicates that this field will store integers (id field). Id will be an identifier and will be different for each new element. When adding a new element to the table, the id will increase by one compared to the previous added element (this is why the id field must have auto-increment (auto increment) and a primary key). This field can be used to identify objects and will help us a lot when we start interacting with the database using php code.

Varchar- a data type that can store a single character or string (up to 8000 characters long). For fields such as first name, last name, and email address, it is quite suitable. You can also set its length. In my example, I set the length to 100 because all the fields in my example with this data type would not take more than 100 characters.

There are various other data types designed to store dates, text, and other data. You can search for information about data types on the Internet. I will also talk about them in the following lessons.


Here you can delete, change and add a field. The interface is intuitive and this will not be difficult to do.

Now I'll show you how insert a new element into a database table.

To do this, click on the top “Insert” tab and a page will open in front of you for inserting a new element into the database table. Fill in all fields (except for the id field, it will be filled in automatically) and click OK.


After you click OK, go to the “Browse” tab (it’s at the top) and you will see the new element you added to your MySQL database table.


On the same page you can delete or change the added element from the database table.

Now I will tell you how to create a new user for the database, create a name and password for him and give him certain privileges. We will need information about the username and password when we connect to the database using a PHP script.

So, create a new user for the database. To do this, click on the name of our database at the top, after which the “Privileges” item will appear in the upper tabs, click on it.


Click “Add user”. You will see a page with fields that need to be filled in (username, host, password and password confirmation). You need to select localhost as the host.


Then click add user and the new user will be added. You will see a message that a user has been added to the new_db database with all privileges.

Here you can also edit privileges by clicking on edit privileges. This may be necessary if someone else should have access to your database, but you want to limit this person's privileges (for example, he cannot delete data). Then you create a new user for your database, but give him certain privileges.

Finally, to delete database you need to go back to the “Databases” tab, select the database to delete and click on the delete link.


Here we looked at the basic operations of interacting with the database through the administration panels.

I would like to say that there is another way to manage a database - using SQL queries. The same queries that we will need to interact with the database from the web page code. In the next lesson I will tell you how add elements, select elements and display them on web pages and you will become familiar with SQL queries against the MySQL database.

I also look forward to your comments on this topic. If the article was useful to you, share it with your friends using the social network buttons.

See you in the next Lesson! Good luck!

A database is a collection of structured and interconnected data and methods that enable the addition, selection and display of data. Microsoft Access allows you to manage all your information from one database file. The following objects are used within this file:

    tables for storing data;

    queries to search and retrieve only the required data;

    forms for viewing, adding and changing data in tables;

    reports for analyzing and printing data in a specific format;

Successful database design ensures that it is easy to maintain. Data should be stored in tables, and each table should contain the same type of information, then it is enough to update specific data in only one place for the updated information to appear throughout the database.

The database for solving the problem consists of:

    1. The “Products” table consists of a list of the product range and contains the name of the product and its code;

      The “Shops” table consists of a list of shops that produce products and contains the name of the shop and its code;

      The “Warehouses” table consists of a list of warehouses where products are stored and contains the name of the warehouse and its code;

      The “Units of Measurement” table consists of a list of the minimum units of production of the assortment and contains the name of the unit of measurement and its code;

      The “Months” table contains the number and name of the month;

      The “Production Plan” table reflects the range and quantity of planned production by month and workshop;

      The “Shop invoices” table contains the numbers and dates of invoices for products produced by the workshops;

      The table “Specifications of shop invoices” contains information about the quantity and range of products issued under a specific invoice.

  1. Requests

    1. The “Plan” query retrieves data on the quantity and range of planned product output for a certain period at a given warehouse;

      The “Fact” query retrieves data on the quantity and range of products produced for a certain period at a given warehouse;

      The “Deviation” query retrieves data on the difference between the quantity of planned product output and the actual quantity for a certain period at a given warehouse.

    1. The “Products” form allows you to edit the “Products” table;

      The “Shop invoices” form allows you to work with the “Shop invoices” table and the subordinate table “Shop invoice specifications”.

    1. The “Surplus Products” report is the result of the “Variance” query

      Table structure.

Data in a database is stored in tables, each of which has its own unique name in the database. In tables, data is organized into columns (called fields) and rows (called records). All data contained in a table field must be of the same type. Each table field is characterized by the name, type and width of the field. When you specify a field's data type, you can also specify the size, format, and other settings that affect the display of the field's value and the precision of the numeric data. Main data types:

    Text. No text or numbers requiring calculations.

    MEMO. This type of field is designed to store small text data (up to 64,000 characters). A field of this type cannot be key or indexed.

    Numerical. This data type contains many subtypes. The accuracy of calculations depends on the choice of subtype (size).

    Counter. Unique, sequentially increasing numbers that are automatically entered when a new record is added to the table.

    Logical. Boolean values, as well as fields that can contain one of two possible values.

    Monetary. Monetary values ​​and numerical data used in mathematical calculations.

    Date Time. Date and time are stored in a special fixed format.

    Object fieldOLE. Includes sound recording, drawing and other types of data. A field of this type cannot be key or indexed.

    Hyperlink. Contains web page addresses.

Data types in table fields

Unit of Measurement Table

Months table

Release plan table

Workshop invoice specification table

Workshop table

One of the main requirements for a DBMS is the ability to quickly search for required records among a large amount of information. Indexes are the most effective tool that can significantly speed up searching for data in tables.

An important feature of indexes is that you can use indexes to create primary keys. In this case, the indexes must be unique. Primary keys and secondary indexes are used to define relationships between tables and data integrity conditions.

The database contains many tables, the relationship between which is established using matching values ​​in key fields. In most cases, you associate a key field in one table with a corresponding field (often with the same name), which is called a foreign key field in a second table. The table containing the key field is called the main table, and the table containing the foreign key is called the linked table.

Field name

Key

Data type

Field size

Number ten. sign.

Table for substations

    Product Table

Item code

Numerical

Product name

Unit code

Numerical

Monetary

Warehouse number

Numerical

    Table Warehouses

Warehouse number

Numerical

Warehouse name

    Workshop table

Workshop number

Numerical

Workshop name

    Table Units of Measurement

Code Units of Measurement

Numerical

Unit name

    Months table

Month number

Yes (No matches allowed)

Numerical

Name of the month

    Release plan table

Workshop number

Numerical

Month number

Numerical

Item code

Numerical

Quantity

Numerical

    Table Workshop invoices

Workshop number

Numerical

Workshop invoice number

Numerical

Due date

Date Time

    TTN Specification Table

Workshop number

Numerical

Workshop invoice number

Numerical

Shop invoices

Item code

Numerical

Quantity

Numerical

      Data schema.

Considering all of the above, let’s draw a data diagram

Fig.3 Data diagram

      Custom forms.

Access forms allow you to create a user interface for database tables. Although you can use Datasheet view to perform the same functions, Forms provide benefits for presenting data in an organized and attractive way. Forms also allow you to create lists of values ​​for fields that use codes to represent multiple valid values. A properly designed form speeds up the data entry process and minimizes errors.

Forms are created from a set of individual controls: text fields for entering and editing data, buttons, checkboxes, radio buttons, lists, field labels, and frames objects for displaying graphics and OLE objects. The form consists of a window that houses two types of controls: dynamic (displaying data from tables), and static (displaying static data such as labels and logos).

Access forms are feature rich; they allow you to perform tasks that cannot be completed in table view. Forms allow you to check the correctness of the data contained in the table. Access allows you to create forms that contain other forms (a form within a form is called a subform). Forms allow you to calculate values ​​and display the result.

In this work, the main push-button form, shop invoices, is used, which contains the subform Specifications of shop invoices.

Fig.4 Form “Workshop invoices”

Fig.5 “Products” form

Figure 6. “Release Plan” form

      Creating queries.

Queries are an important tool in any database management system. They are used to highlight, update and add new records to tables. Most often, queries are used to select specific groups of records to satisfy a specific criterion. They can also be used to retrieve data from different tables, providing a single view of related data items. With these powerful, flexible tools you can:

    Generate complex criteria for selecting records from one or more tables;

    Specify the fields that should be displayed for the selected records;

    Perform calculations using selected data.

There are four types of queries in Access for different purposes:

    Select queries display data from one or more tables in table form.

    Cross-tab queries collect data from one or more tables in a format similar to a spreadsheet. These queries are used to analyze data and create charts based on the total values ​​of numeric values ​​from a set of records.

    Change queries are used to create new tables from query results and to make changes to data in existing tables. They can be used to add or remove records from a table and modify records according to expressions specified in query design mode.

    Queries with parameters are queries whose properties are changed by the user each time they are run. When you run a query with a parameter, a dialog box appears in which you need to enter a selection condition. This type of request is not standalone, i.e. the parameter can be added to any type of request.

In this work, the query was created using the wizard

      Generating reports.

The end product of most database applications is a report. In Access, a report is a special type of continuous form designed to be printed. Access combines data in tables, queries, and even forms to create a report that can be printed and shared. A printed version of the form can serve as a report.

Reports generated by Access are divided into six main types:

    Single column reports are one long column of text containing the values ​​of all fields in each table or query record. The caption indicates the name, and to the right of it the field value is indicated. The new Access AutoReport tool allows you to create a single-column report by clicking the AutoReport toolbar button. Single-column reports are rarely used because this format of presenting data wastes paper.

    IN tape reports For each field of a table or query, a column is allocated, and the values ​​of all fields of each record are displayed on lines, each in its own column. If a record has more fields than can fit on a page, additional pages will be printed until all the data is printed; then printing of the next group of records begins.

    Multi-column reports are created from single-column reports using "newspaper"-style columns or "snake" columns, as is done in desktop publishing systems and word processors. Information that does not fit in the first column is moved to the beginning of the second column, and so on. The multi-column table format saves some paper, but is not applicable in all cases because the column alignment is unlikely to meet user expectations.

In general, reports are easiest to create using the Report Wizard. The Report Wizard tries to create the best possible final report on the first try. Typically, the wizard is close enough to being complete that much less time is spent editing the master's basic report than it would take to create a report from a blank template.

In this work, the report was created using the Report Wizard and then edited in the Report Designer.

Fig.8 Report designer

As a result of running the report, its printed form is obtained.

Fig.9 Report

Conclusion

In business or personal life, you often have to work with data from different sources, each of which is associated with a specific type of activity. Coordinating all this data requires certain knowledge and organizational skills. Microsoft Access combines information from different sources into one relational database. The created forms, queries and reports allow you to quickly and efficiently update data, get answers to questions, search for the necessary data, analyze data, print reports, charts and mailing labels.

In the database, information from each source is stored in a separate table. When working with data from multiple tables, relationships are established between the tables. To search and select data that meets certain conditions, a query is created. Queries also allow you to update or delete multiple records at once, and execute inline and ad-hoc messages.

Forms are used to view, enter or change data directly in the table. A form allows you to select data from one or more tables and display it on the screen using a standard or custom layout.

Reports are used to analyze data or print it in a specific way. For example, you can create a report that groups data and summarizes it, or a report that prints mailing labels.

In the database window you can work with all its objects. To view objects of a certain type, select the appropriate tab. Using the buttons, you can open and modify existing objects and create new ones.

The developed database allows you to quickly and efficiently manage the sales department of finished products. The user-friendly interface of the program, on the one hand, allows you to easily navigate the program without requiring the user to have any special skills in working with electronic computers, on the other hand, it provides the user with operational information.

Designing a database management system in Delphi.

What you need to master:

1) how to connect the database to Delphi components;

2) the procedure for creating an application to manage a simple local database;

3) how to control the display of database tables;

4) how to organize sorting and filtering of data;

5) how to use the SQL query language.

Create a folder in which you will save the applications you develop. For each application in the future, you should create a separate directory in the main folder.

STEP 1. CREATE A SIMPLE DATABASE

Before you begin developing a database management system (DBMS), you should create this database. We will use the Microsoft Office Access application for this purpose, since office is installed on almost any computer and Access was most likely installed by default.

This tutorial will look at the possibilities of accessing databases using only one technology - ADO (Active Data Objects), developed by Microsoft. This modern library, first of all, allows you to work with local MS Access and client-server MS SQL Server databases. Studying this library will allow you in the future to easily move on to databases built on the basis of other technologies.

For now, let's create a local database of a computer literature store, consisting of one table. A table, like a two-dimensional array, consists of columns and rows. Each table column contains a single field, such as book title or author. Each row of the table contains one record consisting of several fields containing, for example, the title of the book, author, price, year of publication.

Launch Microsoft Office Access. In the menu, click File/New and then in the wizard, select New Database. You will be asked to select the database storage location and file name. Specify the path to your first future application (where you will save the Delphi project in the future) and a meaningful name for the computer book store database, for example, mkl.mdb.

A window for organizing work with the database will open (see figure).

Double-click the item “Creating a table in design mode” - the table designer will open, in which you should specify the names of the table fields and the type of data contained in the corresponding fields.

An example of a description of table fields is shown in the figure below. Let there be six fields in the table. In Access, field names can be given names in both English and Russian. The names of fields No. 2-5 are obvious, as is the data type of these fields. Let's look at field #1. Field name: id_kn – book identifier. This field has a special meaning for the database - this is a key field in the table, it carries a unique record identifier. You can set the “Key field” option through the context menu that appears when you right-click on the corresponding field in the table designer. Save the table by clicking on the save button, you will be asked to choose a name for the table - set the name store.


Using the View menu, set the view to Table Mode:

The table is already ready to be filled in, but we will not do this now, since our main goal is to study Delphi's database management capabilities. Let's create an application in Delphi and there we will start editing the table.

STEP 2. CREATE A SIMPLE APPLICATION FOR DATABASE MANAGEMENT

The simplest application should be able to view the contents of the database (in our case, the contents of one table), in addition, there should be functions for correcting records, deleting them, and adding them. A similar task can, of course, be accomplished without the use of database processing technologies, but the development of such an application will take two to three orders of magnitude longer.

So, start Delphi, create a new application and save the project to the folder where the database file is located. Let the module name be magazin.pas, and the project name ProjectMagazin.dpr.

Now let's determine which components from the palette are needed to work with the database. The database consists of tables, to view which you need the corresponding visual component - DBGrid from the Data Controls tab. In addition, there must be other components that provide communication between the application and the location of the database, recognize its format, and make a selection from a specific database table. For these purposes, we use the following three components: ADOConnection and ADOTable from the ADO tab and DataSource from the Data Access tab.

Let's configure the properties of all components on the form.

1. ADOConnection1. Double-click on the component (or in the object inspector on the ConnectionString property line) - you will be given the opportunity to enter a connection string (Use Connection String), launch the wizard by pressing the Build key and on the “Data Provider” tab select the Microsoft Jet OLE DB Provider database connection driver . Click “Next” to go to the “Connection” tab and there, in the “Select or enter a database name” line, enter the file name - in our case it is mkl.mdb. You can, of course, press the key next to the line and directly point to the file, but in this case, it is better to immediately remove the path to the file, leaving only the name, so that when moving the application to another location, there will be no problems with accessing the database. Click OK in the wizard and OK on the connection string selection form. Switch the LoginPromt property to False so that every time you connect to the database the user is not prompted for a password.

2. ADOTable1. In the Connection property, in the drop-down list, point to ADOConnection1, in the TableName property, select the table (we have only one store for now). Set the Active property to True (note that in the future, when changing settings, you will often have to return this property to True). And, for convenience, rename the component to TableMagazin.

3. DataSource1. For this intermediary component, you must set the DataSet property in the drop-down list to the TableMagazin table.

4. DBGrid1. Let's connect the grid with DBGrid1 to the store table from the database using DataSource1 by setting the DataSource property in the drop-down list of available components to DataSource1 in the object inspector.

This completes the creation of the simplest database, and we haven’t written a single line of code. If you already had experience working with these components, you would spend less than a minute developing such a DBMS.

Launch the application using the F9 key and work on filling the database (control keys: F2 – edit cell, Ins – add record, Ctrl+Del – delete record). Close the application and then launch it again and you will see that the changes you made are saved.

Example of filling a database:

Not everyone prefers to work with a keyboard if they have a mouse. Therefore, sometimes the DBNavigator component from the Data Controls tab can be useful. Place it for testing (in the future it should be deleted) on the form at your discretion and connect it using the DataSource1 intermediary - point to it in the DataSource property. If necessary, you can disable some keys from the database control panel in the VisibleButtons property. And, although the control buttons are intuitive, it is possible to provide them with tooltips, for which you set the ShowHint property to True, and the text of the tooltips can be set/changed in the Hints property. A possible view of the application after connecting the DBNavigator component can be seen in the figure:

In the modern world, we need tools that would allow us to store, organize and process large amounts of information that are difficult to work with in Excel or Word. Such repositories are used to develop information websites, online stores and accounting add-ons. The main tools that implement this approach are MS SQL and MySQL. The product from Microsoft Office is a simplified version in terms of functionality and is more understandable for inexperienced users. Let's take a step-by-step look at creating a database in Access 2007.

Description of MS Access

Microsoft Access 2007 is a database management system (DBMS) that implements a full-fledged graphical user interface, the principle of creating entities and relationships between them, as well as the structural query language SQL. The only disadvantage of this DBMS is the inability to work on an industrial scale. It is not designed to store huge amounts of data. Therefore, MS Access 2007 is used for small projects and for personal, non-commercial purposes.

But before showing step-by-step how to create a database, you need to familiarize yourself with the basic concepts of database theory.

Definitions of basic concepts

Without basic knowledge about the controls and objects used when creating and configuring a database, it is impossible to successfully understand the principle and features of setting up a subject area. Therefore, now I will try to explain in simple language the essence of all the important elements. So, let's begin:

  1. A subject area is a set of created tables in a database that are interconnected using primary and secondary keys.
  2. An entity is a separate database table.
  3. Attribute – the title of a separate column in the table.
  4. A tuple is a string that takes the value of all attributes.
  5. A primary key is a unique value (id) that is assigned to each tuple.
  6. The secondary key of table "B" is a unique value from table "A" that is used in table "B".
  7. An SQL query is a special expression that performs a specific action with the database: adding, editing, deleting fields, creating selections.

Now that we have a general idea of ​​what we will be working with, we can begin creating the database.

Creating a database

For clarity of the whole theory, we will create a training database “Students-Exams”, which will contain 2 tables: “Students” and “Exams”. The main key will be the “Record Number” field, because this parameter is unique for each student. The remaining fields are intended for more complete information about students.

So do the following:


That's it, now all that remains is to create, fill and link tables. Continue to the next point.

Creating and populating tables

After successfully creating the database, an empty table will appear on the screen. To form its structure and fill it out, do the following:



Advice! To fine-tune the data format, go to the “Table Mode” tab on the ribbon and pay attention to the “Formatting and Data Type” block. There you can customize the format of the displayed data.

Creating and editing data schemas

Before you start linking two entities, by analogy with the previous paragraph, you need to create and fill out the “Exams” table. It has the following attributes: “Record number”, “Exam1”, “Exam2”, “Exam3”.

To execute queries we need to link our tables. In other words, this is a kind of dependency that is implemented using key fields. To do this you need:


The constructor should automatically create the relationship, depending on the context. If this does not happen, then:


Executing queries

What should we do if we need students who study only in Moscow? Yes, there are only 6 people in our database, but what if there are 6000 of them? Without additional tools it will be difficult to find out.

It is in this situation that SQL queries come to our aid, helping to extract only the necessary information.

Types of requests

SQL syntax implements the CRUD principle (abbreviated from the English create, read, update, delete - “create, read, update, delete”). Those. with queries you can implement all these functions.

For sampling

In this case, the “read” principle comes into play. For example, we need to find all students who study in Kharkov. To do this you need:


What should we do if we are interested in students from Kharkov who have more than 1000 scholarships? Then our query will look like this:

SELECT * FROM Students WHERE Address = “Kharkov” AND Scholarship > 1000;

and the resulting table will look like this:

To create an entity

In addition to adding a table using the built-in constructor, sometimes you may need to perform this operation using an SQL query. In most cases, this is needed during laboratory or course work as part of a university course, because in real life there is no need for this. Unless, of course, you are engaged in professional application development. So, to create a request you need:

  1. Go to the “Creation” tab.
  2. Click the “Query Builder” button in the “Other” block.
  3. In the new window, click on the SQL button, then enter the command in the text field:

CREATE TABLE Teachers
(Teacher Code INT PRIMARY KEY,
Last name CHAR(20),
Name CHAR(15),
Middle name CHAR (15),
Gender CHAR (1),
Date of birth DATE,
main_subject CHAR(200));

where "CREATE TABLE" means creating the "Teachers" table, and "CHAR", "DATE" and "INT" are the data types for the corresponding values.


Attention! Each request must have a “;” at the end. Without it, running the script will result in an error.

To add, delete, edit

Everything is much simpler here. Go to the Create a Request field again and enter the following commands:


Creating a Form

With a huge number of fields in the table, filling the database becomes difficult. You may accidentally omit a value, enter an incorrect one, or enter a different type. In this situation, forms come to the rescue, with the help of which you can quickly fill out entities, and the likelihood of making a mistake is minimized. This will require the following steps:


We have already covered all the basic functions of MS Access 2007. There is one last important component left – report generation.

Generating a report

A report is a special MS Access function that allows you to format and prepare data from a database for printing. This is mainly used for creating delivery notes, accounting reports and other office documentation.

If you have never encountered such a function, it is recommended to use the built-in “Report Wizard”. To do this, do the following:

  1. Go to the "Creation" tab.
  2. Click on the “Report Wizard” button in the “Reports” block.

  3. Select the table of interest and the fields you need to print.

  4. Add the required grouping level.

  5. Select the sort type for each field.