Sie sind auf Seite 1von 55

Wu Jian Min 150100000698

Diploma in Information Technology

Project
DIT IT211 SQL-Structured Query Language [The database of supermarket]

Name: Wu Jian Min Student ID: 150100000698 Class: IT211-Structured Query Language Country: Brunei Lecturer Name: Mrs. Vangie Wenceslao

IT211

Page 1

Wu Jian Min 150100000698

Contents
1. Proposal

Page

1.1 Introduction ...................................................................................................................3 1.2 Problem background.....................................................................................................5 1.3 Proposed system............................................................................................................6 1.4 Objective........................................................................................................................9 2. Database description ................................................................................................10 3. Table Description.........................................................................................................11 4. SQL Command Listing 4.1 Restriction and Projection............................................................................................21 4.2 Arithmetic Expression & Operators.............................................................................22 4.3 Null value handling......................................................................................................23 4.4 Aliases..........................................................................................................................23 4.5 Concatenation............................................................................................................23 4.6 Comparison Operator...................................................................................................24 4.7 Logical Operator..........................................................................................................25 4.8 Sorting..........................................................................................................................26 4.9 Function (Group function & Single Row Function)....................................................27 5.0 Use types of joins ........................................................................................................28 5.1 Subqueries....................................................................................................................29 5. Program Testing 5.1 Test Plan.......................................................................................................................30
IT211 Page 2

Wu Jian Min 150100000698

5.2 Test Cases and Results.................................................................................................32 6. User Manual.................................................................................................................44 7. Conclusion/ Comment.................................................................................................46

IT211

Page 3

Wu Jian Min 150100000698

1. Proposal
Introduction (Background)
Sim Kim Huat supermarket was found in 1970. It is a large supermarket that sells various kinds of goods, such as food, daily products, groceries, toys and so on. Sim Kim Huat currently has a good management. The person who is in charge of the supermarket has created several ideas to control the system of the supermarket. The system of the supermarket can be described as using 6 managements. Those managements are sections, employees, products, stock, sale and customers. The current system of Sim Kim Huat is using paper work to manage the management. (1) Sections The products have been divided into different categories and have been kept in different locations. For example, the location of Daily Products is kept in the location named C1, the location of Home Appliance is kept in another location named C2 and the location of the Furniture is kept in C3. Therefore, customers can find products easily.

(2) Employees: When a person wants to work in Sim Kim Huat supermarket, the applicant will fill in an application form about his or her personal information. The employee information will be kept in a file for future reference. (3) Products The product information, such as model, brand, description, has to be recorded in a product book for future reference. Therefore, employees can order the product that is out of stock from the product information.

IT211

Page 4

Wu Jian Min 150100000698

(4) Stock If the product is out of stock products, it is ordered from suppliers. Usually, an ordering invoice will be issued and send to the suppliers to place new order products. The ordering invoice contains products arrival date, quantity of the products and the name of the supplier. (5) Sales When a customer buys some products, an employee needs to write the name of the customer, the name of the employee serving the customer, the model and the quantity of the selling products in a receipt. (6) Customer The customer information will be recorded in a customer record book for future reference.

IT211

Page 5

Wu Jian Min 150100000698

Problem background
The current system of Sim Kim Huat has some problems since Sim Kim Huat has been using paper to record information. Problems are as follows: Sections Sometimes, employees have a hard time to categorise some products. The products will be displayed in the wrong location. Employees Retrieving information of an employee from the employee information may take a long time to find. Products The quantity of every product in the supermarket will be checked weekly. Sometimes, the quantity of the products will be counted wrongly. Stock The handwriting ordering form has created many problems. Firstly, it is hard to read somebody handwriting. Secondly, some products will be forgotten to place order. Sale The information and quantity of sold products will be recorded by employees. However, they will forget to record some sold products when they are busy. Customer The information of a customer will be hard to retrieve from the customer information.

IT211

Page 6

Wu Jian Min 150100000698

Proposed system
In order to improve the current system and to solve those problems, Sim Kim Huat is planning to use new system. The manager of Sim Kim Huat is going to use databases to store all the information. He is going to break down the information into several tables using Microsoft Access. 1. Sections:
SectionsID S1 S2 Description Daily Product Home Appliance Products Shampoo, comb, perfume Refrigerator, washing machine S3 Furniture Sofa, table

IT211

Page 7

Wu Jian Min 150100000698

2. Employees
EmployeesID FullName Gender Date of birth E1 John M
01/01/1988

Home address Bandar Seri Begawan

Phone number 8122840

Hire Date

Sections ID

Supervisor ID

20/01/1990

S1

E2 E3

Mary Maggie

F M

02/03/1981 21/09/1983

Kiulap Gadong

8299804 8789065

02/02/1989 31/07/1990

S2 S3

E1 E1

3. Products
ProductID P1 P2 P3 Description Shampoo Refrigerator Table & Chair Model A123 B123 C123 Brand Sun Ligo Court Price $9.90 $990 $290 Made Thailand USA Brunei BarCode 123456789 231231231 123565489 SectionsID S1 S2 S3 Qty at hand 50 10 10

4. Stock:
StockID St1 St2 St3 Supplier Thailand USA Brunei ArrivalDate 30/12/2010 30/12/2010 30/12/2010 ProductID P1 P2 P3 Qty 5 5 5

5. Sale:

IT211

Page 8

Wu Jian Min 150100000698

Invoice Number 10000 10001 10002

SellingDate

EmployeesID

CustomerID

ProductID

Qty

TotalPrice

Warranty

1/1/2011 2/1/2011 3/1/2011

E1 E2 E3

1 2 3

P1 P2 P3

1 2 1

$9.90 $1980 $290 One year

6. Customer
CustomerID 1 2 3 CustomerName Phyllis Rose Hafiz Gender F F M Address Tutong Muara Seria Age 20 30 36

IT211

Page 9

Wu Jian Min 150100000698

Objective
The objective of the proposed system is to make the daily transaction of the products faster and easy. The system will be greatly help to trace the information of employees, customers, products and sales. The SQL can be performed to do the calculation of the daily transactions by communicating with a database. For example, the total quantity of a product in the supermarket can be known easily with just a click. Overall, the company can reduce a lot of paperworks, and save a lot of time and human energy.

IT211

Page 10

Wu Jian Min 150100000698

2. Database description
The employees of Sim Kim Huat supermarket are able to gain access to use the database easily by this interface or method. They are able to retrieve the information of each product through the database. This database system is very powerful to keep the information of every linking table by using the primary key of each table. Therefore, the new proposed database can save a lot of memory and the storage in hard disk.

IT211

Page 11

Wu Jian Min 150100000698

3. Table Description
1. Sections: This table is used to locate the products.

Columns purpose: Columns name SectionsID Description Products Its purpose To record new items in sequential number. To describe the categories of products. To describe products.

Columns data type, width of the column and attribute: Columns name SectionsID Description Products Text Text Text 15 255 255 Yes No No No No No Not Allowed Not Allowed Not Allowed Data type Field size Primary key Foreign key Null

2. Employees It is used to keep the information of every employee. The POS of each employee will be collected to show the selling products of each employee.

IT211

Page 12

Wu Jian Min 150100000698

Columns purpose: Columns name EmployeesID Purpose To record new employees in sequential number. FullName Gender Date Of Birth Home Address Phone Number To record the names of the employees. To identify the genders of the employees To record the date of birth of the employees To record the address of the employees To record the phones numbers of the employees them easily Date Started To record the beginning date of hiring of every employee. Sections ID Employees are assigned to manage the categories of products. SupervisorID To record supervisor in sequential number.

Columns data type, width of the column and attribute: Columns name EmployeesID FullName Gender
IT211

Data type

Field size

Primary key

Foreign key

Null

Text Text Text

20 255 10

Yes No No

No No No

Not allowed Not allowed Not Allowed


Page 13

Wu Jian Min 150100000698

Date Of Birth Home Address Phone Number Date Started Sections ID SupervisorID

Date/Time Text

8 bytes 255

No No

No No

Not Allowed Not Allowed

Text

255

No

No

Allowed

Date/Time Text Text

8 bytes 15 15

No No No

No Yes No

Not Allowed Not Allowed Allowed

IT211

Page 14

Wu Jian Min 150100000698

3. Products The table is used to record the information of every product.

Columns purpose Columns name ProductID Description Purpose To record new items in sequential number. To record the description of the new products. Model Brand Price To record the models of the new products. To record the brands of the new products. To record the regular prices of the new products Made To record the products are made from which countries. Barcode SectionsID Qty at hand To record the barcode of each products. To categorize new products. To record the number of rest products

IT211

Page 15

Wu Jian Min 150100000698

Columns data type, width of the column and attribute: Columns name ProductID Description Model Brand Price Made Barcode SectionsID Qty at hand Text Text Text Text Currency Text Text Text Number 15 255 100 100 8 bytes 100 20 15 8 bytes Yes No No No No No No No No No No No No No No No Yes No Not allowed Not allowed Not Allowed Not Allowed Not Allowed Not Allowed Not Allowed Not Allowed Not Allowed Data type Field size Primary key Foreign key Null

IT211

Page 16

Wu Jian Min 150100000698

4. Stock The table is used to record the new order products.

Columns purpose Columns name StockID Supplier ArrivalDate ProductID Purpose To record new orders in sequential number. To record supplier New product arriving date To record the sales of the products. To match information of Products Qty The numbers of new products

Columns data type, width of the column and attribute: Columns name StockID Supplier ArrivalDate ProductID Qty Text Text Date/Time Text Number 15 15 8 bytes 15 8 bytes Yes No No No No No No No Yes No Not allowed Not Allowed Not Allowed Not Allowed Not Allowed Data type Field size Primary key Foreign key Null

5. Sale The table is used to record what products have been sold and how many have been sold.
IT211 Page 17

Wu Jian Min 150100000698

Columns purpose: Columns name InvoiceNumber Sellingdate EmployeesID Purpose To record the sales of the receipts in sequential number To record the date of the sold product To record the ID of the staff. The purpose is used to identify the sold products are sold by which employees. To record which customer purchase the product To record the sales of the products. The quantitis of the sold products. The amount of the sold products. To record how many years warranty the product has.

CustomerID ProductID Qty TotalPrice Warranty

IT211

Page 18

Wu Jian Min 150100000698

Columns data type, width of the column and attribute: Columns name InvoiceNumber Text SellingDate EmployeesID CustomerID ProductID Qty TotalPrice Warranty Date/Time Text Text Text Number Currency Text 15 8 bytes 15 255 15 8 bytes 8 bytes 15 Yes No No No No No No No No No Yes Yes Yes No No No Not Allowed Not Allowed Not Allowed Not Allowed Not Allowed Not Allowed Not Allowed Allowed Data type Field size Primary key Foreign key Null

IT211

Page 19

Wu Jian Min 150100000698

6. Customer This table is used to record customers information in case customer wants to change product that purchase from here. The manager can check this table to confirm it is true. This table is link to sale table.

Columns purpose Columns name CustomerID CustomerName Gender Address Age Purpose To record the customer has been purchased products from here in sequential number To record customers name To record gender of each customer. To record customers address To record customers age

IT211

Page 20

Wu Jian Min 150100000698

Columns data type, width of the column and attribute: Columns name CustomerID Auto Number CustomerName Text Gender Address Age Text Text Number 15 15 255 15 No No No No No No No No Not Allowed Not Allowed Not Allowed Not Allowed 255 Yes No Not Allowed Data type Field size Primary key Foreign key Null

IT211

Page 21

Wu Jian Min 150100000698

4. SQL Command Listing


4.1 Restriction and Projection (1) Retrieve limited rows by using Restriction from Sections table:

Output:

(2) Retrieve limited columns by using projection from Employees table:

Output:

IT211

Page 22

Wu Jian Min 150100000698

4.2 Arithmetic Expression & Operators (3) Arithmetic Expression: Total stock

Output:

Total sold

Output:

Total balance

Output:

IT211

Page 23

Wu Jian Min 150100000698

4.3 Null value handling (4) Using NZ function to retrieve data from Sale:

Output:

4.4 Aliases (5) Change default name from Sale table:

Output:

4.5 Concatenation (6) To concatenate information of products from products table:

Output:

IT211

Page 24

Wu Jian Min 150100000698

4.6 Comparison Operator (7) Using Employees table to do comparison operator:

Output:

(8) Using Employees table to do comparison operator (IS NULL):

Output:

IT211

Page 25

Wu Jian Min 150100000698

4.7 Logical Operator (9) Using Sale table to do Logical Operator by using And function:

Output:

(10) Using Sale table to do Logical Operator by using Or function:

Output:

IT211

Page 26

Wu Jian Min 150100000698

4.8 Sorting (11) Using Sorting function to descend the price of products:

Output:

(12) Using Sorting function to ascend the price of products:

Output:

IT211

Page 27

Wu Jian Min 150100000698

4.9 Function (Single Row Function & Group function) (13) Using Case Conversion function under Customer table:

Output:

(14) Using Format Date under Stock table:

Output:

IT211

Page 28

Wu Jian Min 150100000698

(15) Using Group function under Employees table:

Output:

5.0 Use types of joins (16) Using Equijoin function under Sections table and Employees table:

Output:

IT211

Page 29

Wu Jian Min 150100000698

(17) Using self join function under Employees table

Output:

5.1 Subqueries (18) Using subquery function to display who has the same supervisor as Jasmine under employees table

Output:

IT211

Page 30

Wu Jian Min 150100000698

5. Program Testing
5.1 Test Plan

Test case (1)

Objective To display SectionsID that it is S1 and S3, Description, Products that we want from Sections table To retrieve four columns those are EmployeesID, FullName, HomeAddress, SectionsID from Employees table To calculate remaining quantity of products and display ProductID, QtyAtHand, TotalStock, TotalSold and QtyAtHand.

(2) (3)

(4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16)
IT211

To use None Warranty to represent Null value in Warranty column under Sale table To Aliases Arrival Date as New Arrival Date after arrival date delaying 30 days Using concatenation function to form sentence to introduce products information under products table To retrieve employees who was born before 4/4/1973 To retrieve employees who did not have phone To display products which they was selling out two before 2/1/2011 from sale table To display products which they are in S1 and S3 or they belongs to vegetable from sections table To descend the price of products from Products table To ascend the price of products from Products table To change CustomerName into Capital letter and change Address into Lower case letter from customer table To format date into another type from stock table To count how many employees in employees table To combine Sections and Employees table into one table.
Page 31

Wu Jian Min 150100000698

(17) (18)

To find each employees their supervisor name To find who has the same supervisor as Jamine

IT211

Page 32

Wu Jian Min 150100000698

5.2 Test Cases and Results Test Case: (1) Objective: To display SectionsID that it is S1 and S3, Description, Products that we want from Sections table. Test Data:

Statement:

Expected Test Result: The output result will displayed S1 and S2 rows.

Actual Test Result:

Conclusion: Test successful Test Case: (2) Objective: To retrieve four columns those are EmployeesID, FullName, HomeAddress, SectionsID from Employees table. Test Data:

IT211

Page 33

Wu Jian Min 150100000698

Statement

Expected Test Result: Only EmployeesID, FullName, HomeAddress, SectionsID columns will display.

Actual Test Result:

Conclusion: Test successful Test Case: (3) Objective: To calculate remaining quantity of products and display ProductID, QtyAtHand, TotalStock, TotalSold and QtyAtHand. Test Data:
IT211 Page 34

Wu Jian Min 150100000698

Statement

Expected Test Result: ProductID, QtyAtHand, TotalStock, TotalSold and QtyAtHand columns will display on one table. Actual Test Result:

Conclusion: Test successful

Test Case: (4) Objective: To use None Warranty to represent Null value in Warranty column under Sale table

IT211

Page 35

Wu Jian Min 150100000698

Test Data:

Statement

Expected Test Result: InvoiceNumber, Sellingdate, ProductID, warranty and New Warranty which changes Null value into None warranty will be displayed on one table.

Actual Test Result:

Conclusion: Test successful

IT211

Page 36

Wu Jian Min 150100000698

Test Case: (5) Objective: To Aliases Arrival Date as New Arrival Date after arrival date delaying 30 days table

Test Data:

Statement

Expected Test Result: StockID, Supplier, ArrivalDate and New Arrival Date which date is delayed 30 days will be displayed on one table.

Actual Test Result:

Conclusion: Test successful

Test Case: (6) Objective: Using concatenation function to form sentence to introduce products information under products table

Test Data:
IT211 Page 37

Wu Jian Min 150100000698

Statement

Expected Test Result: We use two sentences to describe the products detail in one table.

Actual Test Result:

Conclusion: Test successful

Test Case: (7) Objective: To retrieve employees who were born before 4/4/1973

Test Data:

Statement

IT211

Page 38

Wu Jian Min 150100000698

Expected Test Result: The information of employees who were born before 4/4/1973 will be displayed.

Actual Test Result:

Conclusion: Test successful

Test Case: (8) Objective: To retrieve employees who did not have phone number

Test Data:

Statement

Expected Test Result:


IT211 Page 39

Wu Jian Min 150100000698

The information of employees who did not have phone number will be displayed.

Actual Test Result:

Conclusion: Test successful

Test Case: (9) Objective: To display products which they were selling out two before 2/1/2011 from sale table

Test Data:

Statement:

Expected Test Result: The information of products which were selling out before 2/1/2011 will be displayed. Actual Test Result:

Conclusion: Test successful


IT211 Page 40

Wu Jian Min 150100000698

IT211

Page 41

Wu Jian Min 150100000698

Test Case: (10) Objective: To display products which they are in S1 and S3 or they belongs to vegetable from sections table Test Data:

Statement

Expected Test Result: The information of products which located S1 and S2 and vegetable products will be displayed. Actual Test Result:

Conclusion: Test successful

Test Case: (11) Objective: To descend the price of products from Products table

Test Data:

IT211

Page 42

Wu Jian Min 150100000698

Statement:

Expected Test Result: The price of products will arrange from higher to lower.

IT211

Page 43

Wu Jian Min 150100000698

Actual Test Result:

Conclusion: Test successful

Test Case: (12) Objective: To ascend the price of products from Products table

Test Data:

Statement:

Expected Test Result: The price of products will arrange from lower to higher.

Actual Test Result:

Conclusion: Test successful


IT211 Page 44

Wu Jian Min 150100000698

Test Case: (13) Objective: To change CustomerName into Capital letter and change Address into Lower case letter from customer table

Test Data:

Statement:

Expected Test Result: The customer name will displayed by using capital letter and address will displayed by using lower case letter. Actual Test Result:

Conclusion: Test successful

Test Case: (14) Objective: To format date into another type from stock table Test Data:

IT211

Page 45

Wu Jian Min 150100000698

Statement:

Expected Test Result: The Arrival Date will be formatted by another form, such as dd-mmm-yyyy.

Actual Test Result:

Conclusion: Test successful

IT211

Page 46

Wu Jian Min 150100000698

Test Case: (15) Objective: To count how many employees in employees table Test Data:

Statement

Expected Test Result: The new table will count number of people in each

Conclusion: Test successful

Test Case: (16) Objective: To combine Sections and Employees table into one table. Test Data:

IT211

Page 47

Wu Jian Min 150100000698

IT211

Page 48

Wu Jian Min 150100000698

Statement

Expected Test Result: The new table will display FullName, DateStarted, Description, SectionsID that are from Employees and Sections table.

Actual Test Result:

Conclusion: Test successful

Test Case: (17) Objective: To find each employees their supervisor name Test Data:

IT211

Page 49

Wu Jian Min 150100000698

Statement

Expected Test Result: The new table will display the information of employees under which supervisor.

IT211

Page 50

Wu Jian Min 150100000698

Actual Test Result:

Conclusion: Test successful

Test Case: (18) Objective: To find who has the same supervisor as Jamine. Test Data:

Statement:

Expected Test Result: The new table will display the information of employees FullName and supervisorID

IT211

Page 51

Wu Jian Min 150100000698

Actual Test Result:

Conclusion: Test successful

IT211

Page 52

Wu Jian Min 150100000698

6. User Manual
Program Installation: 1. Microsoft Access 2007 must be required to install on the computer. 2. Copy supermarket file from Installation CD to any drive or desktop. 3. Double left click supermarket.accdb file to run the program. To run each table steps: 1. All Tables displayed on the left pattern after running the supermarket program.

2. Select any table that user wants. Then just double left click to open the table. For example: Sections table.

IT211

Page 53

Wu Jian Min 150100000698

3. If users want to open query that it already retrieve some information using query. To find icon on the left pattern and double left click to open. For example: Equijoin.

4. If users want to retrieve some information from one table. Click Create under menu bar and click Query Design. Or users want to create new table, then click table after clicking Click Create under menu bar.

IT211

Page 54

Wu Jian Min 150100000698

7. Conclusion/ Comment
I have absorbed a lot of knowledge from my lecturer who has taught us <Structured Query Language> in details. We practiced SQL exercises after each chapter by using Microsoft Access. SQL is used to communicate with a database. Under Microsoft Access software, there are many functions. Now I know how to write basic SQL statements, restrict and sort data, use single-row functions, use multiple-row functions, implement joining tables and write subqueries. And I also know how to define parameters query in Access. SQL is powerful and easy to use. Access can store many data and retrieve data easily that it is simple to write statement using SQL.

IT211

Page 55

Das könnte Ihnen auch gefallen