Professional Documents
Culture Documents
General Objectives
Some DBMS examples include MySQL, Postures, Microsoft Access, SQL Server,
FileMaker, Oracle, RDBMS, DBASE, Clipper, and FoxPro. Since there are so many
database management systems available, it is important for there to be a way for
them to communicate with each other. For this reason, most database software
comes with an Open Database Connectivity (ODBC) driver that allows the database
to integrate with other databases.
Qus-4… Example Following?
1- Entity
2- Attributes
3- Field
4- Records
5- File
Field: - A field is an individual set of data items that are of the same type. If we were to
take an example of a phone book to demonstrate this, the book as a whole would be your
database. It has three fields. The name is one field, the address is another and the phone
number is the third.
Ans… In simple terms a database is a collection of tables that are related and/or unrelated
to each other and can store information in various formats. In the previous tutorial I
showed you how to create a database from scratch, in this tutorial I’ll show how to create
tables (the foundation to any database) for your database using the Design View. When
you create a table you are designing the structure of the table, you assign headings to
columns in your tables, you specify the format of the data that will be entered in the
specified field, you can even add pictures or create equations in table fields, the
possibilities are endless, for now lets stick to basics. If you have any comments or
questions, please post them below.
Note: I used Access XP (2002) to create this tutorial. You can also use the Wizard and
the Create table by entering data option when building your tables.
1. Open your Database, click on the Tables section, double-click Create table in Design
view
2. When you create a table in design view you will be given several options, I’ll highlight
the most important below.
Field Name: The name you will assign to a field in your table (the column) in this case
I’ll want to capture FirstName
Data Type: Depending on the format of the information you will be collecting, you must
pick a format that matches the data, in this case it is a name so I chose Text from the
drop-down
2)- foreign Key:- A foreign key is a field (or fields) that points to the primary key of
another table. The purpose of the foreign key is to ensure referential integrity of the data.
In other words, only values that are supposed to appear in the database are permitted. For
example, say we have two tables, a CUSTOMER table that includes all customer data,
and an ORDERS table that includes all customer orders. The constraint here is that all
orders must be associated with a customer that is already in the CUSTOMER table. In
this case, we will place a foreign key on the ORDERS table and have it relate to the
primary key of the CUSTOMER table. This way, we can ensure that all orders in the
ORDERS table are related to a customer in the CUSTOMER table. In other words, the
ORDERS table cannot contain information on a customer that is not in the CUSTOMER
table.
Table CUSTOMER
Table ORDERS
In the above example, the Customer SID column in the ORDERS table is a foreign key
pointing to the SID column in the CUSTOMER table.
Redundant data wastes disk space and creates database maintenance problems. If data
that exists in more than one place must be changed, the data must be changed in exactly
the same way in all locations. A customer address change is much easier to implement if
that data is stored only in the Customers table and nowhere else in the database.
Do not use multiple fields in a single table to store similar data. For example, to track an
inventory item that may come from two possible sources, an inventory record may
contain fields for Vendor Code 1 and Vendor Code 2. Also, what happens when you add
a third vendor? Adding a field is not the answer; it requires program and table
modifications and does not smoothly accommodate a dynamic number of vendors.
Instead, place all vendor information in a separate table called Vendors, then link
inventory to vendors with an item number key, or vendors to inventory with a vendor
code key.
• Create separate tables for sets of values that apply to multiple records.
• Relate these tables with a foreign key.
Records should not depend on anything other than a table's primary key (a compound
key, if necessary). For example, consider a customer's address in an accounting system.
The address is needed by the Customers table, but also by the Orders, Shipping, Invoices,
Accounts Receivable and Collections tables. Instead of storing the customer's address as
a separate entry in each of these tables, store it in one place, either in the Customers table
or in a separate Addresses table.
Values in a record that are not part of that record's key do not belong in the table. In
general, any time the contents of a group of fields may apply to more than a single record
in the table, consider placing those fields in a separate table.
Ans…- Field Types:- A field is a named unit of information. Each entry in a database
activity module can have multiple fields of multiple types e.g. a text field called
'favourite color' which allows you to type in your favorite shade, or a menu called 'state'
that lets you choose one from a list of the 50 that make up the United States of America.
By combining several fields with appropriate names and types you should be able to
capture all the relevant information about the items in your database.
Field Name:- Access doesn’t impose many rules on what field names you can use. It
lets you use 64 characters of your choice. However, field names are important. You’ll be
referring to the same names again and again as you build forms, create reports, and even
write code. So it’s important to choose a good name from the outset.
Format:- You can use the Format property to customize the way that numbers, dates,
times, and text appear and print. The Format property only controls how the information
in the field appears. The property does not store the information as formatted.
Validate Rule:- You can use the Validation Rule property to specify requirements for
data that are entered in a record, in a field, or in a control. When data is entered that
violates the Validation Rule setting, you can use the Validation Text property to specify
the message that you want to appear when the violation occurs.
Default Value:- You can specify a value for a field that is automatically entered in the
field when a new record is created. For example, in an Addresses table, you can set the
default value for the City field to New York. When you add a record to the table, you
can either accept this value or you can enter the name of a different city.
Ans… Add record in a table: - I have a table of information. I have created a form to
input all the data necessary in order to add a record to the table. The form is not currently
based off of the table and is simply a bunch of text boxes with labels. The reason why I
didn't create the form based off the table is because I don't want all the contents of the
table to be displayed when the form is loaded. I want to form to be solely for adding new
records to the table. I also don't want the form to display any information from the table
when it loads, I want it blank. I don't want any chance of the person that is using the form
to be confused or accidentally be able to edit the data in the table.
Delete in table: - I would like to use a VBA macro in excel to run queries in Access.
This works fine for Select queries, but I get errors when I try to run Make Table queries,
namely that the table already exists.
I can run a macro from Access to drop the tables, but I would like to either do this within
my excel macro, or find some other way to run the make table queries without error
messages.
Visual Basic 6.0 Programming for Add, Edit, Delete, Search Record Ms Access
Database.
Sorting Records: - Sorting records simplifies information retrieval and makes it easier
for you to arrange your database content. These instructions are for Access 97. Open your
database file in Microsoft Access. Use the F11 key to open the Database window. Click
on either the Form tab or the Table tab, depending on which view you want to work in. A
list of forms or tables appears. Click the field that you want to use for sorting records.
MS Access Find and Replace Software lets you find and replace data (characters) in your
Microsoft Access database tables. You decide which tables to make replacements in.
Replacements are not made in special cases such as Booleans (True/False) and primary
keys.
Ans:- Copy:- To move a single cell text from one cell to another, drag and drop it
with button-1 from an unselected source cell to a destination cell (just like dragging an
edge label in a diagram editor). The old text of the destination cell will be overwritten. If
the text is dropped somewhere outside a cell or you click button-2 while dragging, the
command will be aborted. Copying a single cell text from one cell to another works in
the same manner as moving a text. The difference is that the source cell should be
selected.
Delete: - To delete rows, use the Delete Rows command in the Edit menu. This
command deletes every row in which one or more cells are selected. To delete columns,
use the Delete Columns command in the Edit menu. This command deletes every
column in which one or more cells are selected. To delete all cells, use the Delete All
command. This results into an empty table. Before everything is deleted, a question
dialog asks if you are sure about what you are doing. To remove all unused rows and
columns, use the Purge command.
Import: - This article describes how you can use Data Access Objects (DAO) to import
all objects from one Microsoft Access database into the current Access database. In some
situations, this code can be used to recover database objects from a corrupted or damaged
database that can be opened but cannot be compacted successfully.
If a table isn't open in the currently selected work area, the Open dialog box is displayed,
making it possible for you to choose a table to modify.
Changes you can make to a table's structure include adding and deleting fields; modifying
field names, sizes, and data types; adding, deleting, or modifying index tags; and
specifying null value support for fields.
You can also modify the structure of a table using the interface. For more information,
see Modifying the Table Structure.
Caution Changing a field from one data type to another may not transfer the contents of
the field correctly, or at all. For example, if you convert a field of date type to a numeric
type, the field contents do not transfer.
Visual FoxPro automatically makes a backup copy of the current table before you change
the table's structure. When the modifications are complete, the data contained in the
backup copy of the table is appended to the newly modified table structure. If the table
has a memo field, a memo backup file is also created. The table backup file has a
extension, and the memo backup file has a extension.
If you accept the structure changes and then interrupt the data-copying process, the new
file will not contain all the records in the original table.
Remember that Visual FoxPro creates file for the original table file and, if the table has a
memo field, a copy of the original memo file. If you have any problems with MODIFY
STRUCTURE, you can delete the new file or files and rename the back file and file, if
any, to the original file extensions
Qus-17:- Define Relationship?
Ans:- When you create a relationship between tables, the related fields do not have to
have the same names. However, related fields must have the same data type unless the
primary key field is an AutoNumber field. You can match an AutoNumber field with a
Number field only if the FieldSize property of both of the matching fields is the same.
For example, you can match an AutoNumber field and a Number field if the FieldSize
property of both fields is Long Integer. Even when both matching fields are Number
fields, they must have the same FieldSize property setting.
Ans:- Use Access relationships to search for and share data across multiple tables. For
example, suppose you are a potter and want to keep track of your business operations.
You could create one table to keep records of your pottery and a second table to store
records of the galleries that display your work. By creating a relationship between the
two tables, you could run a query that would show where each of your items is currently
being displayed.
1 If you haven't already, assign a Primary Key as a unique identifier in a field in each
table.
2 Close down all tables, then press the F11 key to open the database window. Click
the Relationships icon on the toolbar. If your database has existing relationships defined,
a visual display of these relationships will appear.
3 If your two tables do not appear, click the Show Table icon on the toolbar. The Add
Tables/Queries box will appear.
4 From the Add Tables/Queries box, double-click on the two tables that you want to
relate.
6 This can be the tricky part. Drag the field that you want to relate from one table to
the related field in the other table. This field is usually the Primary Key field in one table.
The Primary Key field in the other table is called the Foreign Key.
Qus-19:- Delete a relationship?
Ans:- Relationships that are no longer needed, or that were entered in error, can be
deleted in Microsoft Access. These instructions apply to Access 97.
Ans:- You should be aware that you can limit the results of a database select query by
using particular criteria. The article relating to Microsoft Access Database Query Basics
gives a breakdown on applying simple query criteria. What if you are not too sure about
what criteria applies to the particular field - wouldn't it be better to be able to choose this
from a list rather than having the standard Microsoft Access input box appear... You can
create a simple Access form, containing a combo box, and base the query criteria on the
value chosen in the form as detailed below: To begin with we will create a table in
Microsoft Access containing some values to search on - the table is shown below: