The schema ORDERPROC for the database ORDERCUST implements an information system for processing orders in a small data center. Information is to be recorded on customers, on contacts, on jobs done for these customers and on the services provided for these orders. The schema ORDERPROC contains the following tables: CUSTOMERS, CONTACTS, ORDERS, SERVICE and ORDSTAT.
The figure below shows an overview of the base tables of the ORDERPROC schema and the dependencies between these tables.
Figure 5: Base table for the ORDERPROC schema; referencing foreign keys have a gray background
CUSTOMERS table
The CUSTOMERS table contains information on the customers. In addition to a unique customer number, the table contains the name, address, telephone number and information on the customer's field of activity. The following table definition is used to create the CUSTOMERS table:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
| |
|
CUST_NUM is the primary key of the CUSTOMERS table. A CHECK constraint has been defined to check the plausibility of the zip codes. The CUSTOMERS table contains the following data:
cust_ num | company | street | zip | city | cou ntry | cust_tel | cust_info |
100 | Siemens AG | Otto-Hahn-Ring 6 | 81739 | Munich | D | 089/636-8 | Electrical |
101 | Login GmbH | Rosenheimer Str. 34 | 81667 | Munich | D | 089/4488870 | PC networks |
102 | JIKO GmbH | Posener Str. 12 | 30659 | Hannover | D | 0551/123874 | Import/Export |
103 | Plenzer Trading | Paul-Heyse-Str. 12 | 80336 | Munich | D | 089/923764 | Fruit trade |
104 | Freddy's Fishery | Hirschgartenstr. 12 | 12587 | Berlin | D | 016/5739921 | Unit retail |
105 | The Poodle Parlor | Am Muehlentor 26 | 41179 | Moenchen- gladbach | D | 040/873562 | Service |
106 | Foreign Ltd. | 26 West York St. | New York, | USA | 001703/2386 532 | Commercial agency | |
107 | Externa & Co KG | Berner Weg 78 | 3000 | Berne 33 | CH | Law firm |
Table 4: Data in the CUSTOMERS table
CONTACTS table
The CONTACTS table contains information on contacts for a specific customer. It comprises a unique contact number, the number of the customer from the CUSTOMERS table, the first name, last name, title and telephone number of the contact and information on the person's position and department along with the reason for the contact. The following table definition is used to create the CONTACTS table:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CONTACT_NUM is the primary key for the CONTACTS table. A referential constraint has been defined for the table. The foreign key CUST_NUM refers to the primary key CUSTOMERS.CUST_NUM of the referenced table CUSTOMERS.
The CONTACTS table contains the following data:
cont | cust _num | fname | lname | title | contact_tel | position | department | contact _info |
10 | 100 | Walter | Kuehne | Dr. | 089/6361896 | CEO | Personnel | |
11 | 100 | Stefan | Walkers | Mr. | 089/63640182 | Secretary | Sales | |
20 | 101 | Roland | Loetzerich | Mr. | 089/4488870 | Managing | Networks | |
25 | 102 | Ewald | Schmidt | Mr. | 0551/123873 | Training | ||
26 | 103 | Beate | Kredler | Ms. | 089/923764 | Organization | SQL | |
30 | 104 | Xaver | Bauer | Mr. | 016/6739921 | Sales exec. | ||
35 | 105 | Anke | Buschmann | Ms. | 02161/584097 | Managing | ||
40 | 106 | Mary | Davis | Ms. | 001703/2386531 | Management | Purchasing | |
41 | 106 | Robert | Heinlein | Mr. | 001703/2386532 | Trainer | Purchasing |
Table 5: Data in the CONTACTS table
ORDSTAT table
The ORDSTAT table allows the order status numbers from the ORDERS table (ORDER_STAT column) to be assigned to the corresponding texts. It contains a unique order status number and the relevant text.
The following table definition is used to create the ORDSTAT table:
|
|
|
|
|
|
|
The ORDSTAT table contains the following data:
order_status | ord_stat_text |
1 | planned |
2 | contract |
3 | completed |
4 | paid |
5 | archived |
Table 6: Data in the ORDSTAT table
ORDERS table
The ORDERS table contains the basic data for an order. It contains a unique order number, references to the customer and the contact person, the order date, the name of the order, the planned and actual completion dates and an order status number. The following table definition is used to create the ORDERS table:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ORDER_NUM is the primary key of the ORDERS table. The foreign key CUST_NUM references the primary key CUSTOMERS.CUST_NUM in the CUSTOMERS table, the foreign key CONTACT_NUM references the primary key CONTACTS.CONTACT_NUM in the CONTACTS table, and the foreign key ORDER_STAT references the primary key ORD_STAT_NUM in the ORDSTAT table.
The DEFAULT clause in the column definition for ORDER_DATE sets the current date as the default value using CURRENT_DATE. The DEFAULT clause for ORDER_STAT sets the default value 1. The ORDERS table contains the following data:
ord er_ | cust_ num | conta ct_nu | order_date | order_text | actual | target | order _stat |
200 | 102 | 25 | 4/15/2009 | Staff training | 5/2/2009 | 5/2/2009 | 5 |
210 | 106 | 40 | 12/15/2009 | Customer management | 4/12/2010 | 4/1/2010 | 3 |
211 | 106 | 41 | 12/29/2009 | Database draft customers | 4/9/2010 | 4/1/2010 | 4 |
250 | 105 | 35 | 1/19/2010 | Instruction concerning mail | 3/3/2010 | 2 | |
251 | 105 | 35 | 1/19/2010 | Customer management | 5/2/2010 | 2 | |
300 | 101 | 20 | 2/16/2010 | Network test/comparison | 1 | ||
305 | 105 | 35 | 4/28/2010 | Staff training | 5/2/2010 | 2 |
Table 7: SQL table ORDERS
SERVICE table
The SERVICE table contains the individual services required by the order. It contains a unique service number, the relevant order number, the date the service was provided, the name of the service, the units in which the service is measured, the number of units, the price per unit, the relevant rate of VAT and the invoice number.
The following table definition is used to create the SERVICE table:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SERVICE_NUM is the primary key of the SERVICE table. The foreign key ORDER_NUM refers to the primary key ORDERS.ORDER_NUM in the ORDERS table.
The SERVICE table contains the following data:
service_ | order_ | service_date | service_text | service_ | service | service_ | vat | inv_num |
1 | 200 | 4/20/2009 | Training | Pages | 45 | 75 | 0.19 | 3 |
2 | 200 | 4/22/2009 | Training | Day | 1 | 1500 | 0.19 | 3 |
3 | 200 | 4/23/2009 | Training | Day | 1 | 1500 | 0.19 | 3 |
4 | 211 | 1/21/2010 | Systems analysis | Day | 8 | 1200 | 0.00 | 10 |
5 | 211 | 1/28/2010 | Database design | Day | 10 | 1200 | 0.00 | 10 |
6 | 211 | 2/16/2010 | Copies/ | Pages | 30 | 50 | 0.19 | 10 |
7 | 211 | 3/24/2010 | Manual | Fixed | 1 | 200 | 0.07 | 10 |
10 | 250 | 2/23/2010 | Travel expenses | Fixed | 2 | 125 | 0.00 | |
11 | 250 | 2/23/2010 | Training | Day | 1 | 1200 | 0.19 |
Table 8: Data in the SERVICE table