Pass Databases by Kenyana Dude
Pass Databases by Kenyana Dude
Qn: Using any database management system of your choice, create a database and save it as KASALE LIMITED.
Instructions:
Create a table and save it as EMPLOYEE_TAB and enter the data in the table above.
Note: the more important things to take into consideration include the following:
1. How to create a database.
2. How to create a table in the database.
3. How to create/add the fields in the table.
4. A look through the choice of appropriate datatype for each field.
5. Entering the records into the table.
Instructions:
Create a table and save it as EMPLOYEE_TAB and enter the data in the table above.
e.g.
- Auto number as “MGM/”000
- Date of Birth as DD-MM-YYYY
Instructions:
Create a table and save it as BASIC_DATA
Add the fields with their correct datatypes
Populate the table with the data above.
Note:
Lookup wizard
Instructions:
Create a table and save it as STAFF_TABLE.
Add the fields to the table with their correct datatypes.
Create a form with all the fields and use it to populate the table.
Notes:
Creating a form
Using a form to population the table
Instructions:
Create a table and save it as BASIC_DATA
Add the fields with their correct datatypes
Populate the table with the data above.
Note:
Lookup wizard
- If you check the BASIC DATA table you will see that all the fields are there: FISHERMANID, NAME, SEX, DOB, CONTACT and
DISTRICT.
- Depending on the query you are creating, to add fields to GRID you simply double click on field names in the table.
Instructions:
Create a table and save it as BASIC_DATA
Populate the table with the data above.
Create a query to display
(a) People whose FNAME starts with letter K, save it as ‘letter k’
(b) People whose SNAME ends with letter S, save it as ‘letter S’
Then click OK and RUN! The query will be displayed. Save the query as letter k and close off the query tab.
In question (b) the display will look like this…
Database Structure
Field name Field format
ItemID SJV-@@@
Item name -
Unit price “ZMW”#,###
Quantity #,###
DOS DD-MMM-YYYY
Location -
Instructions:
Create a query to display the following:
(a) Items with quantity above 500, save it as ‘Above 500’
(b) Items whose quantity is between 800 and 2000, save it as ‘between’
(c) Items with quantity below 1000, save it as ‘below 1000’
(d) Items that cost less 1000, save it as ‘less than 1000’
(e) Items that cost 700 and below, save it as ‘700 and below’
(f) Items whose price is more than 1000, save it as ‘more than’
(g) Items that cost exactly 1500, save it as ‘exactly 1500’
Solutions
(a) In question (a) click on CREATE Tab and go to Query Design. Add table. To create a query with Items with quantity above 500, insert
>500 in Criteria under Quantity Field and then RUN the query. Save the query.
(b) In question (b) in the same quantity field insert ‘between 800 and 2000’ RUN the query. Save the query.
(c) In question (c) in the same quantity field insert ‘<1000’ RUN the query. Save the query.
(d) In question (d) in the Unit Price field insert ‘<1000’ RUN the query. Save the query.
(e) In question (e) in the Unit Price field insert ‘<=700’ RUN the query. Save the query.
(f) In question (f) in the Unit Price field insert ‘>1000’ RUN the query. Save the query.
(g) In question (g) in the Unit Price field insert ‘=1500’ RUN the query. Save the query.
END OF QUESTION
Database Structure
Field name Field format
ItemID SJV-@@@
Item name -
Unit price “ZMW”#,###
Quantity #,###
DOS DD-MMM-YYYY
Location -
Instructions:
Create a query to display the following:
a) Items that were sold in the month of February, save it as ‘February’
b) Items that were sold before April, save it as ‘before April’
c) Items that were sold after April, save it as ‘After April’
Solutions:
a) In question (a) in the DOS (Date of Sale) field criteria insert ‘Month([DOS])=2’ RUN the query. Save the query.
b) In question (b) in the DOS (Date of Sale) field Criteria insert ‘Month([DOS])<4’ RUN the query. Save the query.
c) In question (b) in the DOS (Date of Sale) field Criteria insert ‘Month([DOS])>4’ RUN the query. Save the query.
Instructions:
Create queries that will return the following:
(a) Employees who were born before 1970, save it as ‘born before 1970’
(b) Employees who were born after 1960, save it as ‘born after 1960’
(c) Employees who are above 50 years, save it as ‘above 50 years’
(d) Employees who are below 50 years, save it as ‘below 50 years’
(e) Employees born between 1960 and 1970, save it as ‘born between 1960 and 1970’
Solutions:
(a) In question (a) in the DOB field Criteria insert ‘YEAR([DOB])<1970’ or the other way is insert ‘DatePart(“yyyy”,[DOB])<”1970” RUN
the query. Save the query.
(b) In question (b) in the DOB field Criteria insert ‘YEAR([DOB])>1960’ or the other way is insert ‘DatePart(“yyyy”,[DOB])>”1960”
RUN the query. Save the query.
(c) In question (c) CREATE A NEW FIELD and use the Function called DATEDIFF in GRID PANE AREA insert
‘AGE:DATEDIFF(“YYYY”,[DOB],NOW()). In the Criteria of AGE field insert ‘>50’ RUN the query. Save the query.
(d) In question (d) in the Criteria of AGE field insert ‘<50’ RUN the query. Save the query.
(e) In question (e) in the Criteria of DOB field insert ‘YEAR([DOB]) BETWEEN 1960 AND 1970’ RUN the query. Save the query.
Data Importing
How to import data into the database.
- Make sure that the data to be imported in typed in excel. Note: Data importing in Microsoft Access is not done in Word Processor but data
should be in Excel.
- Therefore, in this case type the above table of data in Microsoft Excel. Give it any name you want, for Import and close it.
- Start the database, in this case you are going to create a new database, give it any name for example, STARLIGHT ACADEMY.
- This is a database without any table. In this case, delete the default table 1 so as it remains a blank database without any table.
- To import data, Click on External Data Tab, then click on excel. This means you are importing data from excel.
- A popup dialogue box will open “Get External Data – Excel Spreadsheet”. Locate your data on where you had save it.
- After locating your excel data, CLICK on “Import the source data into a new table in the current database”. Click OK.
- “Import Spreadsheet Wizard” will pop up, CLICK Next.
- Edit the data type on the next dialogue box “Import Spreadsheet Wizard”. Click Next.
- On the next “Import Spreadsheet Wizard” Choose “CHOOSE MY OWN PRIMARY KEY”. Click Next.
- What will be the table be called? Give it a name. For example, “STUDENT MARKS”. Then click finish and close the dialogue Wizard.
We have finished importing the data into the database.
Create a table and save it as STAFF DATA, use the data in the table above to populate the table: STAFF DATA
Given that Tax is calculated as 15% of the salary, and salary in the following year is increased by 10% of the total salary in the previous year;
Create a query that will return:
a. Total allowances earned by every staff member, save it as STAFF ALLOWANCES
b. The tax deducted from every member’s salary, save it as TAX
c. Total amount earned by every STAFF MEMBER, save it as TOTAL PAY
d. New salary earned by every member in the new year, save it as NEW SALARY
e. The increase from the old to the new salary, save it as INCREASE
Create a query that will automatically update the table filling up the empty fields.
Solutions:
- In Question (a) create a query by CLICKING CREATE TAB – Query Design – add the fields as shown below.