Sunteți pe pagina 1din 14

(UNIT-1)

Qus-1... What is database? Give an Example?

Ans… A database can be thought of as a set of logically related files organized to


facilitate access by one or more applications programs and to minimize data
redundancy. This concept does not imply that all data relating to a company’s
business should be contained on a single database, but simply that all records in a
database should be related and that redundant data should be minimized.

General Objectives

Qus-2… What is relational database? Write its advantages?

Ans… A relational database consists of well defined relations Consisting of


attributes and their values. These relations are called tables and the attributes
are the columns and their values.
A database may consist of various tables having Relationships
among them. These relationships facilitates ease in querying and responses
against the backend database tables.
If that is true, then is this a sign that the once mighty relational database
finally has a chink in its armor? Is this a sign that relational databases have had
their day and will decline over time? In this post, we'll look at the current trend of
moving away from relational databases in certain situations and what this means
for the future of the relational database.

Qus-3… Example DBMS?

Ans… Stands for "Database Management System." In short, a DBMS is a database


program. Technically speaking, it is a software system that uses a standard method
of cataloging, retrieving, and running queries on data. The DBMS manages
incoming data, organizes it, and provides ways for the data to be modified or
extracted by users or other programs.

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

Ans… Entity: - A Maisie program is a collection of C functions and entity definitions.


An entity definition (or an entity type) describes a class of objects. Instances of an entity
type may be created to model object(s) in the physical system. For instance, an entity
type server may be defined to model server objects; specific instances of the server entity
type are created to model server objects in the physical system. Henceforth we will use
the term entity to mean an entity instance…

Attributes:- An object or entity is characterized by its properties or attributes. In


relational database systems attributes corresponds to fields.

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.

Records :- A database record is a row of data in a database table consisting of a single


value from each column of data in the table. The data in the columns in a table are all of
the same type of data, whereas the rows represent a given instance.

Qus-5… Example Relational & its types?


Ans… In the previous example, the fields in five tables must be coordinated so that they
show information about the same order. This coordination is accomplished with
relationships between tables. A relationship works by matching data in key fields —
usually a field with the same name in both tables. In most cases, these matching fields are
the primary key from one table, which provides a unique identifier for each record, and a
foreign key in the other table. For example, employees can be associated with orders
they're responsible for by creating a relationship between the “Employees” table and the”
Orders” table using the EmployeeID fields.

Qus-6… Example Relational Data Integrity Rules?


Ans… Referential integrity is a system of rules that Access uses to ensure that
relationships between records in related tables are valid, and that you don't accidentally
delete or change related data. You can set referential integrity when all of the following
conditions are met:
• The matching field from the primary table is a primary key or has a unique index. A
unique index is an index defined by setting a field's Indexed property to Yes (No
Duplicates). A unique index will not allow duplicate entries in the indexed field. Setting a
field as the primary key automatically designates the field as a unique index.
• The related fields have the same data type. There are two exceptions. An
AutoNumber field can be related to a Number field with a Field Size property setting of
Long Integer, and an AutoNumber field with a Field Size property setting of Replication
ID can be related to a Number field with a Field Size property setting of Replication ID.
• Both tables belong to the same Microsoft Access database. If the tables are linked
tables, they must be tables in Microsoft Access format, and you must open the database
in which they are stored to set referential integrity. Referential integrity can't be enforced
for linked tables from databases in other formats.

Qus-7… Example Datatypes in access?


Ans… The default data type for a Microsoft Access field is text, but you can specify
others. Choosing the most specific data type ensures that you will get the results you want
from your queries and searches. These instructions apply to MS Access 97. Use Text if
your field will contain text (letters) or a combination of letters and numbers, or numbers
that are not currency or will never be calculated. For example, you could select a text data
type for a field that will contain addresses and street numbers or telephone numbers. You
can sort text fields, but they sort alphabetically, not numerically.

Qus-8… Example How to create a table in Access?

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

Qus-9… Example Keys & Its types?


Ans… Sorting like this is an intensive process, which is possible for the small sample
tables being dealt with here. But for a large table with many records, a sort operation can
take a very long time. It is strongly recommended that a primary index, known as a
primary key, is allocated to every table. A primary key is made up of one or more fields
in the database that yield a unique value for each record in the table. When choosing a
primary key for a table you should choose the simplest data that naturally provides
unique values. In addition to preventing duplicate records being entered into the database,
a primary key maintains an order for the table. Whenever new records are added to a
table they are ordered by the primary key field(s).
Qus-10… Example Keys:-
Primary Key
Foreign Key
Super Key
Ans... Primary Key:- Databases depend upon keys to store, sort and compare records.
If you’ve been around databases for a while, you’ve probably heard about many different
types of keys – primary keys, candidate keys, and foreign keys. When you create a new
database table, you’re asked to select one primary key that will uniquely identify records
stored in that table.
The selection of a primary key is one of the most critical decisions you’ll make in the
design of a new database. The most important constraint is that you must ensure that the
selected key is unique. If it’s possible that two records (past, present, or future) may share
the same value for an attribute, it’s a poor choice for a primary key. When evaluating this
constraint, you should think creatively. Let’s consider a few examples that caused issues
for real-world databases:

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.

The structure of these two tables will be as follows:

Table CUSTOMER

column name characteristic


SID Primary Key
Last_Name
First_Name

Table ORDERS

column name characteristic


Order_ID Primary Key
Order_Date
Customer_SID Foreign Key
Amount

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.

Qus-11… Example Normalization?

Ans… Normalization is the process of organizing data in a database. This includes


creating tables and establishing relationships between those tables according to rules
designed both to protect the existing data (accidental deletions or amendments) and to
make the database more flexible by eliminating redundancy and inconsistent
dependency.

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.

What is an "inconsistent dependency"? While it is intuitive for a user to look in the


Customers table for the address of a particular customer, it may not make sense to look
there for the salary of the employee who calls on that customer. The employee's salary is
related to, or dependent on, the employee and thus should be moved to the Employees
table. Inconsistent dependencies can make data difficult to access because the path to find
the data may be missing or broken.

First Normal Form

• Eliminate repeating groups in individual tables.


• Create a separate table for each set of related data.
• Identify each set of related data with a primary key.

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.

Second Normal Form

• 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.

Third Normal Form

• Eliminate fields that do not depend on the key.

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.

For example, in an Employee Recruitment table, a candidate's university name and


address may be included. But you need a complete list of universities for group mailings.
If university information is stored in the Candidates table, there is no way to list
universities with no current candidates. Create a separate Universities table and link it to
the Candidates table with a university code key.

Qus-12… Example field properties in Access?

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.

Qus-13… Example Following?

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.

Edit text in record: -


How to Add, Edit, Delete, Search Record Ms Access Database in VB 6.0, source code
Add, Edit, Delete, Search Record Ms Access Database in VB 6.0. To make the program
add, edit, delete, search Ms Access Database in Visual Basic 6.0 need some control that
is Adodc, DataGrid and a Module to connect database to visual basic 6.0. Read how to
Connect Ms Access Database to Visual Basic 6.0.

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.

Qus-14: Example Follwing?


Ans… Find & Replace:- MS Access Find and Replace Software lets you search for
and replace data in your Microsoft Access database tables

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.

Qus-15: - Example following table editing commands?

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.

Qus-16:- Example How to Modify table & stricture?

Ans: - In previous versions of FoxPro, MODIFY STRUCTURE opens the Table


Structure dialog box.

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.

Qus-18:- Add a relationship?

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.

 5 Close the Add Tables/Queries dialog box.

 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.

1. Close any open tables.


2. Open the Database window (you can access it by hitting the F11 key).
3. Click the Query tab.
4. From the Query window, click the Relationship button in the toolbar or
select Relationships from the Tools menu.
5. A window appears. Rectangular shapes joined by lines appear. Each
rectangle represents a table, and the lines represent relationships between
tables.
6. Click on the line that represents the relationship you want to delete.
7. Right-click to obtain a menu. Select Delete. Alternatively, while the line is
selected, click Delete from the Edit menu. The relationship is deleted.

Qus-20:- Queries & Filter (Different between queries and filter)?

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:

The table that will be used to create the query on.

S-ar putea să vă placă și