course 5 Access
course 5 Access
1-Introduction
MPD : This step consists of implementing the model in the DBMS, that is to say
translating it into a data definition language, such as: SQL.( Structured Query Language)
The DBMS “DataBase Management Systems” is software that allows managing databases.
• Create a DB
• Question the DB
2- Some constraints
• Two tables in the same database cannot have the same name.
• Two fields in the same table cannot have the same name.
• The names of tables and fields must not contain a space or a special character
such as: “é” or “{”, but they can contain a “_”.
1
INFORMATIQUE 2EME ANNEE
For create a
new DB
Examples
of DB
Name
of DB
4- Interface Access :
Formatting
buttons
Tables of
DB
The columns
of table 1
Access tabs
Note: Table 1 is a table automatically created by Access, because you cannot create a
database that does not contain a table.
2
INFORMATIQUE 2EME ANNEE
5- Creation of Tables:
To create a new table in our new database, we click on the “Create” tab then on
“Table Creation” and the table will be created, but it will be empty (i.e. without
columns and without rows)
We can now enter the rows (or lines) of the table which are called
records(“enregistrements” in French), and here is an example:
3
INFORMATIQUE 2EME ANNEE
After creating this table you can enter, delete, modify records.
Note: in the IDprod column if we enter an ID that already exists access will display an
error message and also if we want to enter a new product without typing its ID access
will display another error message.
6- Field types:
Numeric: By default, it is an integer but you can specify if it is a real number.
This field format allows you to enter numbers in different formats:
Byte: (octet in French) integers from 0 to 255.
Integer (2 bytes): (Entier in French) integers between - 32,768 and + 32,767.
Long integers (4 bytes): between -2 147 483 648 and + 2 147 483 647
Real: Access uses the scientific writing of real numbers. Example: if we write
in Access the number: -123456 it will be displayed: -1.23456E+05.
-123456 = - 1,23456 x 10 5
The automatic number is a long integer. It is assigned by the system, and the user
cannot change it. The increment can be regular (+1), or random (signed numbers).
The same number is never assigned twice.
Attention ! When a line is deleted, the automatic number will not be reused by the system.
Text: allows you to create a field with mixed letters and numbers. You
cannot do calculations in these types of fields. We can specify its size
(but if we don't change it, it will be equal to 255 characters).
Memo: is equivalent to TEXT but can contain more information. The
maximum size is 65 535 characters.
Yes/No: this corresponds to fields which can only take one of the two
values YES or NO. (for example: amount paid or not)
Date/Time: Type of fields which indicate a notion of time. Several
formats are available. For example :
Monetary (4 bytes): numbers between -922 337 203 685 477.5808 and
922 337 203 685 477.5807
Note: the monetary type uses the Windows default monetary and to change it you
must modify the Windows regional settings.
5
INFORMATIQUE 2EME ANNEE
6
INFORMATIQUE 2EME ANNEE
Example2: if we have a field in our database called “Expiration date” and we want
to enter only unexpired products, we can write in the field of “valid if”: “> Date( )”, and
the system will only accept unexpired products.
Message if error: This allows you to display a message in the case of invalid
data (in the case of using Valid if).
Example: if we take the previous example, our system must display an error message
if we want to enter an expired product. Here is the error message:
Null prohibited :(Null interdit ) If the choice is yes, data must be entered.
Example: if we take the previous example, if we enter a product without entering
its expiration date, Access will display the following message: