You are on page 1of 15

DBMS PRACTICAL FILE

i.
CREATE TWO TABLES EMPLOYEE AND DEPARTMENT WITH THE FOLLOWING STRUCTURE AND ALSO CREATE A RELATIONSHIP BETWEEN THESE TWO TABLES.

EMPLOYEE TABLE:
FELID DATA TYPE

EMPID EMPNAME
ADDRESS SALARY MANAGERID DEPNO PHONE

NUMBER TEXT
TEXT NUMBER NUMBER NUMBER NUMBER

DEPARTMENT TABLE :
FIELD DNUMBER DNAME EMPID DOJ STEPS: DATA TYPE NUMBER TEXT NUMBER DATE

I.

OPEN MS ACCESS AND CLICK ON BLANK DATABASE

&

CLICK CREATE .

A NEW BLANK DATABASE IS OPENED .

II.

GO TO THE DESIGN VIEW OF THE TABLE AND GIVE THE NAME OF THE TABLE AS

EMPLOYEE
TABLE .

AND SAVE IT ,

SIMILARLY DO THE SAME FOR

DEPARTMENT
III. OPEN
THE FIELDS.

THE TABLE

GO TO DESIGN

VIEW AND GIVE THE DATA TYPES OF

ii.

APPLY THE FOLLOWING CONSTRAINTS AND CREATE RELATIONSHIP BETWEEN ABOVE TWO TABLES AND

( EMPLOYEE EMPLOYEE TABLE :


FIELDS EMPID EMPNAME ADDRESS SALARY

DEPARTMENT

TABLES). CONSTRAINT PRIMARY KEY

SHOULD NOT BE MORE THAN

60000

MANAGERID DEPNO PHONE DEPARTMENT TABLE FIELD DNUMBER DNAME EMPID DOJ STEPS FOREIGN KEY OF EMPLOYEE TABLE FOREIGN KEY OF DEPARTMENT TABLE VALIDATION

(99999-00000)

:
CONSTRAINT PRIMARY KEY

:
GO TO DESIGN VIEW , RIGHT CLICK ON THE LEFT SIDE MARGIN OF THE FIELD TO ASSIGN THE PRIMARY KEY . FOR OTHER CONSTRAINTS, GO TO THE FIELD PROPERTIES

1) 2)

THERE IN THE VALIDATION RULE

< 60000 CLICK OK .


TYPE

FOR SALARY DATA FIELD . A DIALOG BOX WILL APPEAR

TYPE

, < 60000 AND

3)

FOR THE PHONE NUMBER , SELECT PHONE NUMBER DATA FIELD AND GO TO INPUT MASK FROM FIELD PROPERTIES AND TYPE

(99999-00000).

STEPS:

1) 2) 3) 4)

TO CREATE RELATIONSHIP, GO TO DATABASE TOOLS

CLICK ON RELATIONSHIP MENU, THEN A

DIALOG BOX WILL APPEAR USE CTRL N SELECT BOTH THE TABLES AND CLICK CLOSE . JOIN THE DEPNO OF EMPLOYEE TABLE WITH DNUMBER OF DEPARTMENT TABLE , A DIALOG BOX WILL COME , CLICK ON REFERENTIAL INTEGRITY AND CLICK CREATE . RELATIONSHIP WILL BE CREATED

SIMILARLY DO THE SAME FOR EMPID OF DEPARTMENT TABLE

AND EMPID OF EMPLOYEE , JOIN THEM BY CLICKING N DRAGGING . SELECT REFERENTIAL INTEGRITY AND CREATE RELATION .

III. WRITE a)

FOLLOWING SQL QUERIES FOR ABOVE TABLES.

INSERT NEW RECORD IN EMPLOYEE TABLE : STEPS:

1) 2) 3)

GO TO CREATE MENU

CLICK ON QUERY DESIGN AND

RIGHT CLICK ON QUERY 1 AND

SELECT SQL VIEW AND TYPE THE QUERY IN THAT SPACE AND SAVE IT , IT WILL BE SHOWN ON LEFT SIDE DOUBLE CLICK ON THAT TO GET THE OUTPUT

b)

SELECT EMPLOYEES WORKING IN RESEARCH DEPARTMENT AND SORT THE RESULT BY EMPLOYEE NAME .

c)

COUNT THE NUMBER OF EMPLOYEES IN RESEARCH DEPARTMENT AND THEIR AVERAGE SALARY .

d)

COUNT NUMBER OF EMPLOYEES IN EACH DEPARTMENT AND THEIR AVERAGE SALARY.

e)

CHANGE THE NAME OF RESEARCH DEPARTMENT TO

RESEARCH

AND DEVELOPMENT DEPARTMENT

.
IV. WHAT
ARE THESE OBJECTS? TABLES, QUERIES, FORMS, REPORTS ,PAGES,MACROS,MODULES .

1. Tables-: A database table is similar in appearance to a spreadsheet, in that data is stored in rows and columns. As a result, it is usually quite easy to import a spreadsheet into a database table. The main difference between storing your data in a spreadsheet and storing it in a database is in how the data is organized. To get the most flexibility out of a database, the data needs to be organized into tables so that redundancies don't occur. For example, if you're storing information about employees, each employee should only need to be entered once in a table that is set up just to hold employee data. Data about products will be stored in its own table, and data about branch offices will be stored in another table. This process is called normalization. 2. Forms-: Forms are sometimes referred to as "data entry screens." They are the interfaces you use to work with your data, and they often contain command buttons that perform various commands. You can create a database without using forms by simply editing your data in the table datasheets. However, most database users prefer to use forms for viewing, entering, and editing data in the tables. 3. Reports-: Reports are what you use to summarize and present data in the tables. A report usually answers a specific question, such as "How much money did we receive from each customer this year?" or "What cities are our customers located in?" Each report can be formatted to present the

information in the most readable way possible. A report can be run at any time, and will always reflect the current data in the database. Reports are generally formatted to be printed out, but they can also be viewed on the screen, exported to another program, or sent as e-mail message. 4. Queries-: Queries are the real workhorses in a database, and can perform many different functions. Their most common function is to retrieve specific data from the tables. The data you want to see is usually spread across several tables, and queries allow you to view it in a single datasheet. Also, since you usually don't want to see all the records at once, queries let you add criteria to "filter" the data down to just the records you want. Queries often serve as the record source for forms and reports. Certain queries are "updateable," meaning you can edit the data in the underlying tables via the query datasheet. If you are working in an updateable query, remember that your changes are actually being made in the tables, not just in the query datasheet. 5. Macros-: Macros in Access can be thought of as a simplified programming language which you can use to add functionality to your database. For example, you can attach a macro to a command button on a form so that the macro runs whenever the button is clicked. Macros contain actions that perform tasks, such as opening a report, running a query, or closing the database. Most database operations that you do manually can be automated by using macros, so they can be great time-saving devices. 6. Modules-: Modules, like macros, are objects you can use to add functionality to your database. Whereas you create macros in Access by choosing from a list of macro actions, you write modules in the programming language. A module is a collection of declarations, statements, and procedures that are stored together as a unit. A module can be either a class module or a standard module. Class modules are attached to forms or reports, and usually contain procedures that are specific to the form or report they're attached to. Standard modules contain general procedures that aren't associated with any other object. Standard modules are listed under Modules in the Navigation Pane, whereas class modules are not.
V.
CREATE A FORM FOR EMPLOYEE TABLE USING THE FORM WIZARD . STEPS:

1) 2) 3)

GO TO CREATE , CLICK ON MORE FORMS ICON , CHOOSE FORM WIZARD. ALL THE FIELDS OF THE EMPLOYEE TABLE , CHOOSE APPROPRIATE LAYOUT AND CLICK NEXT TO SELECT THE STYLE . CLICK ON FINISH TO GET THE FORM.

VI. CREATE REPORT


STEPS:

FROM THE EMPLOYEE TABLE THROUGH REPORT WIZARD?

1) 2) 3) 4)

GO TO CREATE

CHOOSE REPORT LOGO FROM THE MENU.

DO THE EDITING SAVE THE REPORT DOUBLE CLICK TO RUN AND SEE THE REPORT .

VII.

MAKE A FORM WITH FORM DESIGN VIEW USING THESE TOOL

(LABEL ,

TESTBOX , CHECK

BOX , LIST BOX STEPS:

IMAGE ).

1)

GO TO CREATE AND CHOOSE FORM DESIGN .

2) 3)

CHOOSE LABEL,TEXT BOX , CHECK BOX , LIST BOX , IMAGE LOGO N DRAW THEM ON THE FORM. SAVE THE FORM AND DOUBLE CLICK ON IT TO RUN IT .

VIII.

DEFINE DIFFERENT TYPES OF QUERIES WITH EXAMPLE OF EACH ? ALSO APPLY CRITERIA AND

SORT ON QUERY ACCORDING TO EMPLOYEE TABLE ?

1. Create Table Query-: CREATE TABLE (Table name) (column_name1 data_type, column_name2 data_type, column_name3 data_type); Example-: CREATE TABLE DEPARTMENT (DNAME TEXT (NOT NULL), DNUMBERNUMBER NOT NULL MGRSSN TEXT, MGRSTARTDATE TEXT); 2. DROP TABLE DEPENDENT Query-: DROP TABLE (Table Name) Example-: ALTER TABLE EMPLOYEE ADD JOB TEXT (12);

3. ALTER TABLE Query-: ALTER TABLE (table name) ADD (column name) column-definition; Example-: ALTER TABLE supplier ADD (supplier name) text (25); 4. DELETE Query-: Alter Table (table name) Drop (column name); EXAMPLE-: alter table supplier Drop (supplier name);
IX. APPLY
DIFFERENT FORMATTING ON A TABLE INCLUDING TITLE , DATE AND TIME AND LOGO?

STEPS:

1) 2) 3) 4) 5)

GO TO CREATE

CHOOSE FORM DESIGN .

A BLANK FORM WILL BE OPENED , CHOOSE THE MENU(S) TITLE , LOGO,DATE AND TIME FROM THE MENU BAR. CLICK AND DRAG TO DRAW THE ABOVE . SAVE THE FORM DOUBLE CLICK ON IT , TO SEE THE RESULT .

X.

DIFFERENCE BETWEEN DESIGN VIEW , DATASHEET VIEW , FORM VIEW , LAYOUT VIEW AND WIZARD ?

DESIGN VIEW-: IT ALLOWS YOU TO CREATE OR CHANGE THE TABLE, FORM, OR OTHER DATABASE OBJECT , AND CONFIGURE THE FIELDS. YOU CAN ALSO SET KEYS AND RESTRICT THE VALUES ENTERED HERE . B UT YOU CAN'T CHANGE THE DATABASE DATA IN DESIGN VIEW . DATASHEET VIEW-: DATASHEET
VIEW SHOWS THE DATA IN THE DATABASE .

IT

ALSO ALLOWS

YOU TO ENTER AND EDIT THE DATA .

IT

DOES NOT LET YOU CHANGE THE FORMAT OF THE

DATABASE , OTHER THAN MINOR CHANGES

(SUCH

AS DISPLAYED COLUMN WIDTHS).

FORM FORM

VIEWS-:

WINDOW THAT USUALLY DISPLAYS ONE OR MORE WHOLE RECORDS .

FORM

VIEW IS THE PRIMARY MEANS OF ADDING AND MODIFYING DATA IN TABLES, VIEW , GO TO THE

TO

OPEN A FORM IN

DATABASE WINDOW, CLICK FORMS UNDER OBJECTS, CLICK THE FORM YOU WANT TO OPEN , AND THEN CLICK O PEN ON THE D ATABASE WINDOW TOOLBAR . LAY OUT VIEW-: A VIEW WHERE YOU CAN BETTER ORGANIZE YOUR MAP ELEMENTS TO LOOK NICE FOR PRINTED OUTPUT OR FOR EXPORTING AS A GRAPHIC FILE . YOU CAN DISPLAY MULTIPLE DATA FRAMES IN THE LAYOUT VIEW , ALONG WITH OTHER ELEMENTS SUCH AS A LEGEND, NORTH ARROW, SCALE , TITLE , ETC

WIZARD-: A MICROSOFT ACCESS

TOOL THAT ASKS YOU QUESTIONS AND CREATES AN

OBJECT ACCORDING TO YOUR ANSWERS.

FOR

EXAMPLE , YOU CAN CREATE TABLES, QUERIES,

FORMS, REPORTS , OR DATA ACCESS PAGES BY USING WIZARDS.

You might also like