Está en la página 1de 32

C.

SQL and the TMWSuite data model


The TMWSuite database resides in Microsoft SQL (MSSQL) Server, a relational database. Many third party tools can retrieve its data (e.g., Crystal Reports, Microsoft Access, etc). The Query Analyzer that comes with MSSQL is a simple, but powerful tool for browsing though your database.

Simplified TMWSuite data model


Mo ve (crossdock) mov_number

OrderHeader

LegHeader (Trip Segment)

ord_hdrnumber Stops referencenumber.ref_tablekey =orderheader.ord_hdrnumber referencenumber.ref_table =orderheader referencenumber.ref_tablekey =stops.stp_number referencenumber.ref_table =stops

lgh_number

stp_number

lgh_number

ReferenceNumbers

FreightDetail

Event evt_number

ord_hdrnumber

referencenumber.ref_tablekey =freightdetail.fgt_number referencenumber.ref_table =freightdetail

AssetAssignment asgn_number

InvoiceHeader ivd_hdrnumber

PayDetail

payheader.pyh_pyhnumber = paydetail.pyh_number PayHeader

InvoiceDetail

Simplified TMWSuite Data Model


Table names are displayed in boxes. The links between tables are the names of columns that the tables share.

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.1 TMWSuite System Administration

SQL and the TMWSuite data model

Key TMWSuite tables


Orderheader The orderheader table contains general and summary information about each order in your database. One orderheader record exists for each order entered into your system. There is a one to one relationship between orderheader records and order numbers. There is one stop record for every point that you dispatch a truck to or through. At a minimum, a trip consists of two stops a loading point and a delivery point. The legheader table represents trip segments. Typically, a trip segment is the part of a move that was handled by a driver/tractor. If the driver/tractor dropped the loaded trailer for subsequent re-hook by another, there would be two trip segments for the entire move. Otherwise, there would be just the one. There is no actual Move table within TMWSuite. However, stops are tied together by move numbers to represent the movement of a loaded trailer from the initial loading point to the final delivery point. Moves also include stops that represent the deadhead or bobtail origins and destinations that are associated with the loaded trailer movement. The event table contains a record for each event that occurs at a stop. Typically, there would be only one. We call this the primary event. This table provides an index into the history of each resource (driver, tractor, trailer, carrier) in your system.

Stops

Legheader

Move

Event Assetassignment

Referencenumber This table records every reference number that you enter into the system. You can use this table to look up orders by reference number. Freightdetail Invoiceheader Invoicedetail Paydetail Payheader This table contains the description of the freight that is picked up/delivered at each stop. Every invoice is represented by a single invoiceheader record. Each line item on an invoice is represented by an invoicedetail record. All earnings, advances, expense reimbursements, and deductions are represented by paydetail records. For each driver (or tractor, trailer, carrier), for each pay period, there is one payheader record. This record contains the summary of driver pay for that pay cycle.

C.2 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

Links between master tables and transactional tables


The following table is an abbreviated list of the key links between the master profile tables and the transactional tables. Company cmp_id= Order header ord_company (ordered by) ord_originpoint ord_destpoint ord_supplier ord_billto ord_shipper ord_consignee ord_showshipper ord_showconsignee Leg header cmp_id_start cmp_id_end Invoice header ivh_billto ivh_shipper ivh_consignee ivh_originpoint ivh_destpoint ivh_supplier ivh_orderby ivh_showshipper ivh_showconsignee

AssetAssignment asgn_type=DRV asgn_id= asgn_type=TRC asgn_id= asgn_type=TRL asgn_id= asgn_type=CAR asgn_id= PayDetail asgn_type=DRV asgn_id= asgn_type=TRC asgn_id= asgn_type=TRL asgn_id= asgn_type=CAR asgn_id= PayHeader asgn_type=DRV asgn_id= asgn_type=TRC asgn_id= asgn_type=TRL asgn_id= asgn_type=CAR asgn_id=

ManpowerProfile mpp_id TractorProfile trc_number TrailerProfile trl_id Carrier car_id ManpowerProfile mpp_id TractorProfile trc_number TrailerProfile trl_id Carrier car_id ManpowerProfile mpp_id TractorProfile trc_number TrailerProfile trl_id Carrier car_id

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.3 TMWSuite System Administration

SQL and the TMWSuite data model

Sample SQL queries


Get a list of orders, restricted by ship date, and then total the line haul charges: SELECT ord_number, ord_billto, ord_charge FROM orderheader WHERE ord_startdate BETWEEN '1/1/00' and '12/31/00' AND ord_charge > 0 Now, summarize line haul charges by bill to (introduce GROUP BY): SELECT ord_billto, sum(ord_charge) FROM orderheader WHERE ord_startdate BETWEEN '1/1/00' and '12/31/00' AND ord_charge > 0 GROUP BY ord_billto Now, include the name of the customer (introduces JOIN): SELECT ord_billto, cmp_name, sum(ord_charge) FROM orderheader, company WHERE orderheader.ord_billto = company.cmp_id AND ord_startdate BETWEEN '1/1/00' and '12/31/00' AND ord_charge > 0 GROUP BY ord_billto, cmp_name Now, lets have a look at the pickup and delivery points for an order (introduces order by, and points out that ord_hdrnumber is not the same as the order number): SELECT stops.stp_event, company.cmp_name, stops.stp_lgh_mileage FROM stops, company, orderheader WHERE stops.cmp_id = company.cmp_id AND stops.ord_hdrnumber = orderheader.ord_hdrnumber AND ord_number = '1435' ORDER BY stp_mfh_sequence This query looks at total empty and total loaded miles by driver for a specified date range (introduces assetassignment table and complex joins): SELECT sum(stops.stp_lgh_mileage), stops.stp_loadstatus, manpowerprofile.mpp_lastfirst FROM stops, legheader, assetassignment, manpowerprofile WHERE legheader.lgh_number = stops.lgh_number AND assetassignment.lgh_number = legheader.lgh_number AND assetassignment.asgn_id = manpowerprofile.mpp_id AND assetassignment.asgn_type = 'DRV' AND stops.stp_lgh_mileage > 0 AND asgn_date BETWEEN '1/1/00' and '9/1/00' GROUP BY stops.stp_loadstatus, manpowerprofile.mpp_lastfirst Here, we will retrieve summarized revenue by charge item type: SELECT cht_description, SUM(ivd_charge) FROM invoiceheader, invoicedetail, chargetype WHERE invoiceheader.ivh_billdate BETWEEN '1/1/00' and '8/1/00' AND chargetype.cht_itemcode = invoicedetail.cht_itemcode AND invoicedetail.ivh_hdrnumber = invoiceheader.ivh_hdrnumber GROUP BY cht_description Order By cht_description
C.4 TMWSuite System Administration Rev. 4/2003 TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

Order Entry / Dispatch

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.5 TMWSuite System Administration

SQL and the TMWSuite data model

C.6 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.7 TMWSuite System Administration

SQL and the TMWSuite data model

C.8 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

Manpower profile

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.9 TMWSuite System Administration

SQL and the TMWSuite data model

C.10 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.11 TMWSuite System Administration

SQL and the TMWSuite data model

C.12 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.13 TMWSuite System Administration

SQL and the TMWSuite data model

C.14 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

File Maintenance

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.15 TMWSuite System Administration

SQL and the TMWSuite data model

C.16 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.17 TMWSuite System Administration

SQL and the TMWSuite data model

C.18 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.19 TMWSuite System Administration

SQL and the TMWSuite data model

C.20 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.21 TMWSuite System Administration

SQL and the TMWSuite data model

C.22 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

Billing

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.23 TMWSuite System Administration

SQL and the TMWSuite data model

C.24 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.25 TMWSuite System Administration

SQL and the TMWSuite data model

C.26 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

Rating

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.27 TMWSuite System Administration

SQL and the TMWSuite data model

C.28 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

Settlements

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.29 TMWSuite System Administration

SQL and the TMWSuite data model

C.30 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

SQL and the TMWSuite data model

STL-B1

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

Rev. 4/2003

C.31 TMWSuite System Administration

SQL and the TMWSuite data model

System Administration

C.32 TMWSuite System Administration

Rev. 4/2003

TMW Systems, Inc. C.SQLandTMWSDataModel.doc

También podría gustarte