Skip to content

Office Operational Database

Andy Theuninck edited this page Jul 9, 2015 · 4 revisions

CustomerAccountSuspensions

Name Type Info
customerAccountSuspensionID INT PK Increment
card_no INT Indexed
active TINYINT Indexed
tdate DATETIME
suspensionTypeID SMALLINT
reasonCode INT
legacyReason TEXT
username VARCHAR(50)
savedType VARCHAR(10)
savedMemType SMALLINT
savedDiscount SMALLINT
savedChargeLimit MONEY
savedMailFlag TINYINT

Use: Proposed replacement for suspensions. Not in use yet.

CustomerAccounts

Name Type Info
customerAccountID INT PK Increment
cardNo INT Indexed
memberStatus VARCHAR(10) Default='PC'
activeStatus VARCHAR(10) Default=''
customerTypeID INT Default=1
chargeBalance MONEY Default=0
chargeLimit MONEY Default=0
idCardUPC VARCHAR(13)
startDate DATETIME
endDate DATETIME
addressFirstLine VARCHAR(100)
addressSecondLine VARCHAR(100)
city VARCHAR(50)
state VARCHAR(10)
zip VARCHAR(10)
contactAllowed TINYINT Default=1
contactMethod VARCHAR(10) Default='mail'
modified DATETIME
This model has yet to be documented

CustomerNotifications

Name Type Info
customerNotificationID INT PK Increment
cardNo INT
customerID INT Default=0
source VARCHAR(50)
type VARCHAR(50)
message VARCHAR(255)
modifierModule VARCHAR(50)

Use: Display account specific or customer specific messages in various ways at the lane.

Customers

Name Type Info
customerID INT PK Increment
customerAccountID INT
cardNo INT
firstName VARCHAR(50)
lastName VARCHAR(50)
chargeAllowed TINYINT Default=1
checksAllowed TINYINT Default=1
discount TINYINT Default=0
accountHolder TINYINT Default=0
staff TINYINT Default=0
phone VARCHAR(20)
altPhone VARCHAR(20)
email VARCHAR(50)
memberPricingAllowed TINYINT Default=0
memberCouponsAllowed TINYINT Default=0
lowIncomeBenefits TINYINT Default=0
modified DATETIME
This model has yet to be documented

FloorSections

Name Type Info
floorSectionID INT PK Increment
storeID INT Default=1
name VARCHAR(50)
This model has yet to be documented

HouseVirtualCoupons

Name Type Info
card_no INT PK
coupID INT PK
description VARCHAR(100)
start_date DATETIME
end_date DATETIME

Depends on:

  • houseCoupons
  • houseCouponItems

Use: Assign house coupons to members so they can be applied without scanning a barcode

IgnoredBarcodes

Name Type Info
upc VARCHAR(13) PK
reason VARCHAR(50) Default='PLU Item'
This model has yet to be documented

MasterSuperDepts

View

Name Type Info
superID INT
super_name VARCHAR(50)
dept_ID INT

View

Use: A department may belong to more than one superdepartment, but has one "master" superdepartment. This avoids duplicating rows in some reports. By convention, a department's "master" superdepartment is the one with the lowest superID.

PriceRuleTypes

Name Type Info
priceRuleTypeID INT PK Increment
description VARCHAR(50)
This model has yet to be documented

PriceRules

Name Type Info
priceRuleID INT PK Increment
priceRuleTypeID INT
minMargin DOUBLE Default=0
maxPrice DOUBLE Default=0
reviewDate DATETIME
details TEXT
This model has yet to be documented

ProdCostHistory

Name Type Info
prodCostHistoryID BIGINT UNSIGNED PK Increment
upc VARCHAR(13) Indexed
modified DATETIME
cost MONEY
uid INT
prodUpdateID BIGINT UNSIGNED Indexed
This model has yet to be documented

ProductOriginsMap

Name Type Info
originID INT PK
upc VARCHAR(13) PK
active TINYINT Default=1

Depends on:

  • origins
  • products

Use: Maps products to multiple origins. A product has a single "current" origin via products.current_origin_id but a product from multiple locations could also occur. Produce is the most common use case.

PurchaseOrder

Name Type Info
orderID INT PK Increment Default=0
vendorID INT
creationDate DATETIME
placed TINYINT Indexed Default=0
placedDate DATETIME
userID INT
vendorOrderID VARCHAR(25)
vendorInvoiceID VARCHAR(25)
standingID INT

Use: Stores general an order from a vendor. One or more records in purchaseOrderItems should go with this record to list the individual items to order.

vendorOrderID and vendorInvoiceID are memo fields. If the vendor puts numbers or other identifiers on orders and/or invoices those values can be saved here for reference.

PurchaseOrderItems

Name Type Info
orderID INT PK
sku VARCHAR(13) PK
quantity INT
unitCost MONEY
caseSize INT
receivedDate DATETIME
receivedQty INT
receivedTotalCost MONEY
unitSize VARCHAR(25)
brand VARCHAR(50)
description VARCHAR(50)
internalUPC VARCHAR(13)

Depends on:

  • PurchaseOrder (table)
  • vendorItems (table)

Use: Contains items to be purchased as part of an order from a vendor.

quantity is the number of cases ordered. unitCost corresponds to vendorItems.cost and caseSize corresponds to vendorItems.units. The estimated cost of puchase for the line will be quantity * unitCost * caseSize.

The received fields are for when the items are actually delivered. receivedQty may not match quantity and receivedTotalCost may not match the estimated cost.

unitSize, brand, description, and internalUPC are simply copied from vendorItems. If the vendor discontinues a SKU or switches it to a different product, this record will still

PurchaseOrderSummary

Name Type Info
vendorID INT PK
sku VARCHAR(13) PK
totalReceived INT
casesReceived INT
numOrders INT
numCredits INT
oldest DATETIME
newest DATETIME

Depends on:

  • PurchaseOrder
  • PurchaseOrderItems

Use: Stores total quantities ordered for recent orders where "recent" covers the same timeframe as transarchive. Calculating this on the fly can be prohibitively slow.

totalReceived is in individual units for comparison against sales records. casesReceived is in cases.

numOrders indicates how many times the item has been ordered. Credits are counted separately as numCredits. oldest and newest are bounds on when the item has been ordered.

ServiceScaleItemMap

Name Type Info
serviceScaleID INT PK
upc VARCHAR(13) PK

Depends on:

  • ServiceScales
  • scaleItems

Use: Join table to record which items are

ServiceScales

Name Type Info
serviceScaleID INT PK Increment
description VARCHAR(50)
host VARCHAR(50)
scaleType VARCHAR(50)
scaleDeptName VARCHAR(25)
superID INT
epDeptNo SMALLINT Default=1
epStoreNo SMALLINT Default=0
epScaleAddress SMALLINT Default=1

Use: List service scales and network info.

ShelfTagQueues

Name Type Info
shelfTagQueueID INT PK Increment
description VARCHAR(50)
This model has yet to be documented

ShrinkReasons

Name Type Info
shrinkReasonID INT PK Increment
description VARCHAR(30)
This model has yet to be documented

SpecialDeptMap

Name Type Info
specialDeptModuleName VARCHAR(100) PK
dept_no INT PK
This model has yet to be documented

Stores

Name Type Info
storeID INT PK Increment
description VARCHAR(50)
dbHost VARCHAR(50)
dbDriver VARCHAR(15)
dbUser VARCHAR(25)
dbPassword VARCHAR(25)
transDB VARCHAR(20)
opDB VARCHAR(20)
push TINYINT Default=1
pull TINYINT Default=1

Use: List of known stores. By convention storeID zero should NOT be used; it represents all stores combined.

The local store should have an entry containing at least dbHost so it can identify itself. The other database credentials are not necessary for the local store since they must be known already to access the table.

Entries for remote stores need full credentials. Setting up user accounts with read-only to remote

VendorBreakdowns

Name Type Info
vendorID INT PK
sku VARCHAR(13) PK
upc VARCHAR(13)
This model has yet to be documented

autoCoupons

Name Type Info
coupID INT PK
description VARCHAR(30)

Depends on:

  • houseCoupons
  • houseCouponItems

Use: Apply coupons to transactions automatically Deprecated. The houseCoupons table has the same functionality built in.

batchBarcodes

Name Type Info
upc VARCHAR(13) PK
description VARCHAR(30)
normal_price MONEY
brand VARCHAR(50)
sku VARCHAR(14)
size VARCHAR(50)
units VARCHAR(15)
vendor VARCHAR(50)
pricePerUnit VARCHAR(50)
batchID INT PK

Depends on:

  • batches (table)

Use: This table has information for generating shelf tags for a batch. This makes sense primarily when working with batches that update items' regular price rather than sale batches.

Note: size relates to an indivdual product. Units relates to a case. So a case of beer has 24 units, each with a size of 12 oz.

batchCutPaste

Name Type Info
batchID INT PK
upc VARCHAR(13) PK
uid INT PK
tdate DATETIME

Depends on:

  • batchList (table)

Use: This table is a clipboard for batches. uid is the logged in user, so multiple people can "cut" to their own clipboard.

You should probably truncate this table occasionally. I do daily.

batchList

Name Type Info
listID INT PK Increment
upc VARCHAR(13) Indexed
batchID INT Indexed
salePrice MONEY
active TINYINT
pricemethod SMALLINT Default=0
quantity SMALLINT Default=0

Depends on:

  • batches (table)

Use: This table has a list of items in a batch. In most cases, salePrice maps to products.special_price AND products.specialgroupprice, pricemethod maps to products.specialpricemethod, and quantity maps to products.specialquantity.

WFC has some weird exceptions. The main on is that upc can be a likecode, prefixed with 'LC'

batchMergeTable

Name Type Info
startDate DATETIME
endDate DATETIME
upc VARCHAR(13) PK
description VARCHAR(30)
batchID INT PK

Use: This is a speedup table for reports. It's populated (daily) by a scheduled task. It unrolls likecoded batchList entries back into upcs which simplifies subsequent queries. At WFC batchList is also a bit large and slow to join against directly.

batchType

Name Type Info
batchTypeID INT PK
typeDesc VARCHAR(50)
discType INT

Use: This table contains types of batches that can be created. You really only need one for each discount type, but you can have more for organizational purposes

batches

Name Type Info
batchID INT PK Increment
startDate DATETIME
endDate DATETIME
batchName VARCHAR(80)
batchType SMALLINT
discountType SMALLINT
priority INT
owner VARCHAR(50)
transLimit TINYINT Default=0

Depends on:

  • batchType

Use: This table contains basic information for a sales batch. On startDate, items in batchList with a corresponding batchID go on sale (as specified in that table) and with the discount type set here. On endDate, those same items revert to normal pricing.

cronBackup

Name Type Info
modified DATETIME
file_contents TEXT

Use: Store a copy of webserver's crontab in case update goes awry

custAvailablePrefs

Name Type Info
custAvailablePrefID INT Increment
pref_key VARCHAR(50) PK
pref_default_value VARCHAR(100)
pref_description TEXT

Use: List of available customer preferences

custPreferences

Name Type Info
custPrefenceID INT Increment
card_no INT PK
custAvailablePrefID INT
pref_key VARCHAR(50) PK
pref_value VARCHAR(100)

Depends on:

  • custdata (table)
  • custAvailablePrefs (table)

Use: Store customer-specific preferences This table supplements custdata and is available at the lanes.

custReceiptMessage

Name Type Info
card_no INT Indexed
msg_text VARCHAR(255)
modifier_module VARCHAR(50)

Depends on:

  • custdata (table)

Use: Create member-specific messages for receipts.

  • card_no is the member number
  • msg_text is the message itself
  • modifier_module is [optionally] the name of a class that should be invoked to potentially modify the message. An equity message, for example, might use a modifier module to check and see if payment was made in the current transaction

custdata

Name Type Info
CardNo INT Indexed
personNum TINYINT
LastName VARCHAR(30) Indexed
FirstName VARCHAR(30)
CashBack MONEY
Balance MONEY
Discount SMALLINT
MemDiscountLimit MONEY Default=0
ChargeLimit MONEY Default=0
ChargeOk TINYINT Default=0
WriteChecks TINYINT Default=1
StoreCoupons TINYINT Default=1
Type VARCHAR(10) Default='PC'
memType TINYINT
staff TINYINT Default=0
SSI TINYINT Default=0
Purchases MONEY Default=0
NumberOfChecks SMALLINT Default=0
memCoupons INT Default=1
blueLine VARCHAR(50)
Shown TINYINT Default=1
LastChange TIMESTAMP
id INT PK Increment Default=0

Use: This is one of two "primary" tables dealing with membership (the other is meminfo). Of the two, only custdata is present at the checkout. Column meaning may not be quite identical across stores.

[Probably] The Same Everywhere:

  • CardNo is the member's number. This identifies them.
  • personNum is for stores that allow more than one person per membership. personNum starts at 1. The combination (CardNo, personNum) should be unique for each record.
  • FirstName what it sounds like.
  • LastName what it sounds like.
  • Discount gives the member a percentage discount on purchases.
  • Type identifies whether the record is for an actual member. If Type is 'PC', the person is considered a member at the register. This is a little confusing, but not everyone in the table has to be a member.
  • blueLine is displayed on the checkout screen when the member's number is entered.
  • id just provides a guaranteed-unique row identifier. [20Feb2014 Use of these fields is becoming more general]
  • ChargeOk=1 if member may run a store charge balance; =0 may not.
  • MemDiscountLimit is their store charge account limit. (Deprecated in favour of ChargeLimit)
  • ChargeLimit is their store charge account limit.
  • Balance is a store charge balance as of the start of the day, if the person has one. Some records are for organizations, esp vendors, that have charge accounts. Is updated from ar_live_balance by cronjob arbalance.sanitycheck.php and by its replacement cron/tasks/ArHistoryTask.php

[Probably] Just For Organizing: The register is mostly unaware of these settings, but they can be used on the backend for consistency checks e.g., make sure all staff members have the appropriate percent discount

  • staff identifies someone as an employee. Value: 1?
  • memType allows a little more nuance than just member yes/no. FK to memtype.memtype
  • SSI probably because of a historic senior citizen discount. (Sounds like it is obsolete or at least not used.)

WFC Specific:

  • memCoupons indicates how many virtual coupons (tender MA) are available.

[Probably] Ignored: To the best of my (Andy's) knowledge, these have no meaning on the front or back end.

  • CashBack
  • WriteChecks
  • StoreCoupons
  • Purchases
  • NumberOfChecks
  • Shown

Maintenance:

  • Single edit: fannie/mem/search.php
  • Single add: fannie/mem/new.php
  • Batch import: fannie/mem/import/*.php

custdataBackup

Name Type Info
CardNo INT Indexed
personNum TINYINT
LastName VARCHAR(30) Indexed
FirstName VARCHAR(30)
CashBack MONEY
Balance MONEY
Discount SMALLINT
MemDiscountLimit MONEY Default=0
ChargeLimit MONEY Default=0
ChargeOk TINYINT Default=0
WriteChecks TINYINT Default=1
StoreCoupons TINYINT Default=1
Type VARCHAR(10) Default='PC'
memType TINYINT
staff TINYINT Default=0
SSI TINYINT Default=0
Purchases MONEY Default=0
NumberOfChecks SMALLINT Default=0
memCoupons INT Default=1
blueLine VARCHAR(50)
Shown TINYINT Default=1
LastChange TIMESTAMP
id INT PK Increment Default=0

Use: Stores an older snapshot of custdata Easier to pull small bits of info from

customReceipt

Name Type Info
text VARCHAR(80)
seq INT PK
type VARCHAR(20) PK

Use: This table contains strings of text that originally lived in the lane's ini.php. At first it was only used for receipt headers and footers, hence the name. Submit a patch if you want a saner name.

Current valid types are:

  • receiptHeader
  • receiptFooter
  • ckEndorse
  • welcomeMsg
  • farewellMsg
  • trainingMsg
  • chargeSlip

customReports

Name Type Info
reportID INT PK
reportName VARCHAR(50)
reportQuery TEXT

Use: Save queries for later use as reports

dateRestrict

Name Type Info
upc VARCHAR(13) Indexed
dept_ID INT Indexed
restrict_date DATE
restrict_dow SMALLINT
restrict_start TIME
restrict_end TIME

Depends on:

  • products (table)
  • departments (table)

Use: Store restrictions for selling products at certain dates & times. Restrictions can be specified by UPC or department number as well as by exact date or day of week. If start and end times are entered, restriction will only apply during that span

departments

Name Type Info
dept_no SMALLINT PK
dept_name VARCHAR(30) Indexed
dept_tax TINYINT
dept_fs TINYINT
dept_limit MONEY
dept_minimum MONEY
dept_discount TINYINT
dept_see_id TINYINT Default=0
modified DATETIME
modifiedby INT
margin DOUBLE
salesCode INT
memberOnly SMALLINT Default=0

Use: Departments are the primary level of granularity for products. Each product may belong to one department, and when items are rung up the department setting is what's saved in the transaction log

dept_no and dept_name identify a department

dept_tax,dept_fs, and dept_discount indicate whether items in that department are taxable, foodstampable, and discountable (respectively). Mostly these affect open rings at the register, although WFC also uses them to speed up new item entry. dept_see_id is for departments where customers should show ID (e.g., alcohol). The value is the age required for purchase.

dept_limit and dept_minimum are the highest and lowest sales allowed in the department. These also affect open rings. The prompt presented if limits are exceeded is ONLY a warning, not a full stop.

margin is desired margin for products in the department. It can be used for calculating retail pricing based on costs. By convention, values are less than one. A value of 0.35 means 35% margin. This value has no meaning on the lane.

salesCode is yet another way of categorizing items. It is typically used for chart of account numbers. Often the financial accounting side of the business wants to look at sales figures differently than the operational side of the business. It's an organizational and reporting field with no meaning on the lane.

memberOnly restricts sales based on customer membership status. Values 0 through 99 are reserved. 100 and above may be used for custom settings. Currently defined values: 0 => No restrictions 1 => Active members only (custdata.Type = 'PC') 2 => Active members only but cashier can override 3 => Any custdata account except the default non-member account

disableCoupon

Name Type Info
upc VARCHAR(13) PK
threshold SMALLINT Default=0
reason text

Use: Maintain a list of manufacturer coupons the store does not accept. Most common usage is coupons where a store does carry products from that manufacturer but does not carry any products the meet coupon requirements. In theory family codes address this situation better, but obtaining and maintaing those codes isn't feasible.

employees

Name Type Info
emp_no SMALLINT PK
CashierPassword VARCHAR(50)
AdminPassword VARCHAR(50)
FirstName VARCHAR(50)
LastName VARCHAR(50)
JobTitle VARCHAR(50)
EmpActive TINYINT
frontendsecurity SMALLINT
backendsecurity SMALLINT
birthdate DATETIME

Use: Table of cashiers. emp_no identifies a cashier uniquely. CashierPassword and AdminPassword are numeric passcodes used pretty interchangably (should probably match). EmpActive toggles whether an account can actually log in. frontendsecurity is used to restrict certain actions at the register based on security level.

houseCouponItems

Name Type Info
coupID INT PK
upc VARCHAR(13) PK
type VARCHAR(15)

Use: WFC runs custom barcoded coupons with upc prefix 499999. See houseCoupons for more detail. Type here should be 'QUALIFIER',

houseCoupons

Name Type Info
coupID INT PK
description VARCHAR(30)
startDate DATETIME
endDate DATETIME
limit SMALLINT
memberOnly SMALLINT
discountType VARCHAR(2)
discountValue MONEY
minType VARCHAR(2)
minValue MONEY
department INT
auto TINYINT Default=0

Use: WFC runs custom barcoded coupons with upc prefix 499999, then the coupon ID (zero padded to 5 digits). There's a tool in legacy for putting these together that may eventually make it into fannie.

startDate is the first day the coupon is valid

endDate is the last day the coupon is valid

limit is the number of times the coupon can be used in one transaction

memberOnly means the coupon can only be used by a member (custdata.Type='PC')

minType and minValue specify how one qualifies for the coupon - certain item(s), purchase amount, etc

  • 'Q' must purchase at least minValue qualifying items (by quantity)
  • 'Q+' must purchase more than minValue qualifying items (by quantity)
  • 'D' must purchase at least minValue items from qualifying departments (by $ value)
  • 'D+' must purchase more than minValue items from qualifying departments (by $ value)
  • 'M' is mixed. Must purchase at least minValue qualifying items and at least one discount item
  • '$' must puchase at least minValue goods (by $ value)
  • '$+' must puchase more than minValue goods (by $ value)
  • '' blank means no minimum purchase

discountType and discountValue specify how the discount is calculated

(item related discounts)

  • 'Q' discount equals discountValue times unitPrice for the cheapest qualifying item (essentially percent discount)
  • 'P' discount equals unitPrice minus discountValue for the cheapest qualifying item (essentially an sale price)
  • 'FI' discount equals discountValues times quantity for the cheapest qualifying item (works with by-weight items)

(department related discounts)

  • 'FD' discount equals discountValue times quantity for the cheapest qualifying item
  • 'AD' discount equals discountValue times sum(quantity) for ALL qualifying items

(other discounts)

  • 'F' discount equals discountValue
  • '%' discountValue is a percent discount for all discountable items

Qualifying items are stored in houseCouponItems. Not all coupons require entries here. Records can be items (by UPC) or departments (by department number). Some minimum and discount types only work with one or the other.

houseCouponItems.coupID is the coupon ID

houseCouponItems.upc is an item UPC or a department number.

houseCouponItems.type is only relevant to the mixed (M) minimum type. Values are:

  • 'QUALIFIER' counts as a qualifying item for mixed
  • 'DISCOUNT' counts as a discount item for mixed
  • 'BOTH' can be a qualfying item or a discount item If not using the mixed minimum, always choose 'BOTH'

The nuts and bolts of this are in the UPC.php parser module (IT CORE).

likeCodes

Name Type Info
likeCode INT PK
likeCodeDesc VARCHAR(50)

Use: Like Codes group sets of items that will always have the same price. It's mostly used for produce, but could be applied to product lines, too (e.g., all Clif bars)

The actual likeCode => upc mapping is in upcLike

memContact

Name Type Info
card_no INT PK
pref INT

Use: Contact preferences 0 => no contact 1 => snail mail 2 => email 3 => both

memContactPrefs

Name Type Info
pref_id INT PK
pref_description VARCHAR(50)

Use: List of available member contact preferences Describes values in memContact.pref

memDates

Name Type Info
card_no INT PK
start_date DATETIME
end_date DATETIME

Use: Start and end dates for a membership. Both date fields optional.

memberCards

Name Type Info
card_no INT PK Default=0
upc VARCHAR(13) PK

Use: WFC has barcoded member identification cards. card_no is the member, upc is their card.

memberNotes

Name Type Info
memberNoteID INT PK Increment
cardno INT Indexed
note TEXT
stamp DATETIME
username VARCHAR(50)

Depends on:

  • custdata (table)

Use: This table just holds generic blobs of text associated with a given member. Used to make a note about a membership and keep a record of it.

meminfo

Name Type Info
card_no INT PK Default=0
last_name VARCHAR(30)
first_name VARCHAR(30)
othlast_name VARCHAR(30)
othfirst_name VARCHAR(30)
street VARCHAR(255)
city VARCHAR(20)
state VARCHAR(2)
zip VARCHAR(10)
phone VARCHAR(30)
email_1 VARCHAR(50)
email_2 VARCHAR(50)
ads_OK TINYINT Default=1
modified DATETIME

Depends on:

  • custdata (table)

Use: This table has contact information for a member, i.e. it extends custdata on card_no. See also: memContact.

Usage doesn't have to match mine (AT). The member section of fannie should be modular enough to support alternate usage of some fields.

card_no key to custdata and other customer tables.

Straightforward:

  • street varchar 255
  • city
  • state
  • zip
  • phone long enough to include extension but don't put more than one number in it.

The name fields are for two different people. This approach will work if your co-op allows only 1 or 2 people per membership, but custdata can hold the same information in a more future-proof way, i.e. support any number of people per membership, so better to not use them in favour of custdata.

  • email_1 for email

  • email_2 for second phone

  • ads_OK EL: Perhaps: flag for whether OK to send ads. Don't know whether implemented for this or any purpose.

memtype

Name Type Info
memtype TINYINT PK Default=0
memDesc VARCHAR(20)
custdataType VARCHAR(10)
discount SMALLINT
staff TINYINT
ssi TINYINT

Use: Housekeeping. If you want to sort people in custdata into more categories than just member/nonmember, use memtype.

The custdataType, discount, staff, and ssi are the default values for custdata's Type, discount, staff, and ssi columns when creating a new record of a given memtype.

originCountry

Name Type Info
countryID INT PK Increment
name VARCHAR(50)
abbr VARCHAR(5)

Use: This table lists countries

originCustomRegion

Name Type Info
customID INT PK Increment
name VARCHAR(50)

Use: This table lists custom defined regions (counties, neighborhoods, internal jargon, etc)

originStateProv

Name Type Info
stateProvID INT PK Increment
name VARCHAR(50)
abbr VARCHAR(5)

Use: This table lists major sub-national divisions (e.g., US States, Canadian

origins

Name Type Info
originID INT PK Increment
countryID INT
stateProvID INT
customID INT
local TINYINT Default=0
name VARCHAR(100)
shortName VARCHAR(50)

Depends on:

  • originCountry
  • originStateProv
  • originCustomRegion

Use: This table defines locations. The IDs correspond to the other origin tables. The local field indicates whether or not this origin is considered local by the co-op.

parameters

Name Type Info
store_id SMALLINT PK
lane_id SMALLINT PK
param_key VARCHAR(100) PK
param_value VARCHAR(255)
is_array TINYINT

Use: Partial replacement for ini.php. This differs from the lane_config table. This contains actual values where as lane_config contains PHP code snippets that can be written to a file.

Values with store_id=0 (or NULL) and lane_id=0 (or NULL) are applied first, then values with the lane's own lane_id are applied second as local overrides. A similar precedent level based on store_id may be added at a later date.

patronage

Name Type Info
cardno INT PK Default=0
purchase MONEY
discounts MONEY
rewards MONEY
net_purch MONEY
tot_pat MONEY
cash_pat MONEY
equit_pat MONEY
FY SMALLINT PK Default=0
check_number INT
cashed_date DATETIME
cashed_here TINYINT Default=0
This model has yet to be documented

prodDepartmentHistory

Name Type Info
prodDepartmentHistoryID BIGINT UNSIGNED PK Increment
upc VARCHAR(13) Indexed
modified DATETIME
dept_ID INT
uid INT
prodUpdateID BIGINT UNSIGNED Indexed

Depends on:

  • prodUpdate (table)

Use: This table holds a compressed version of prodUpdate. A entry is only made when an item's department setting changes. uid is the user who made the change.

prodExtra

Name Type Info
upc VARCHAR(13) PK
distributor VARCHAR(100)
manufacturer VARCHAR(100)
cost MONEY
margin DOUBLE
variable_pricing TINYINT
location VARCHAR(30)
case_quantity VARCHAR(15)
case_cost MONEY
case_info VARCHAR(100)

Depends on:

  • products (table)

Use: Don't add to it. As of 20Oct2012 it is still used by item/productList.php.

Deprecated. This mess dates back to trying to stay lock-step with the Wedge's products table (which didn't work anyway). The thinking was "Need a new field? Toss it in prodExtra".

prodFlags

Name Type Info
bit_number TINYINT PK
description VARCHAR(50)
active TINYINT Default=1

Depends on:

  • products (table)

Use: Properties for the product table's numflag column

prodPhysicalLocation

Name Type Info
upc VARCHAR(13) PK
store_id SMALLINT Default=0
floorSectionID INT
section SMALLINT Default=0
subsection SMALLINT Default=0
shelf_set SMALLINT Default=0
shelf SMALLINT Default=0
location INT Default=0

Depends on:

  • products (table)

Use: Storing physical location of products within a store.

Floor Section ID replaces section and subsection to areas of the store can be given human-readable names rather than using a pure numbering system.

Section and/or subsection represents a set of shelves. In a lot of cases this would be one side of an aisle but it could also be an endcap or a cooler or something against a wall that isn't formally an aisle. A store can use either or both. For example, section could map to aisle numbering and subsection could indicate the left or right side of that aisle. Another option would be to map section to a super department (e.g., grocery) and subsection to an aisle-side within that department.

"Shelf set" is a division within a subsection. It could be one physical shelving unit or a freezer door.

Shelf indicates the vertical shelf location. Bottom to top numbering is recommended.

Location is the horizontal location on the shelf.

prodPriceHistory

Name Type Info
prodPriceHistoryID BIGINT UNSIGNED PK Increment
upc VARCHAR(13) Indexed
modified DATETIME
price MONEY
uid INT
prodUpdateID BIGINT UNSIGNED Indexed

Depends on:

  • prodUpdate (table)

Use: This table holds a compressed version of prodUpdate. A entry is only made when an item's regular price setting changes. uid is the user who made the change.

prodUpdate

Name Type Info
prodUpdateID BIGINT UNSIGNED PK Increment
updateType VARCHAR(20)
upc VARCHAR(13) Indexed
description VARCHAR(50)
price MONEY
salePrice MONEY
cost MONEY
dept INT
tax TINYINT
fs TINYINT
scale TINYINT
likeCode INT
modified DATETIME
user INT
forceQty TINYINT
noDisc TINYINT
inUse TINYINT

Depends on:

  • products (table)

Use: In theory, every time a product is change in fannie, the update is logged here. In practice, not all tools/cron jobs/sprocs/etc actually do. They probably

productBackup

Name Type Info
upc VARCHAR(13) Indexed
description VARCHAR(30) Indexed
brand VARCHAR(30)
formatted_name VARCHAR(30)
normal_price MONEY
pricemethod SMALLINT
groupprice MONEY
quantity SMALLINT
special_price MONEY
specialpricemethod SMALLINT
specialgroupprice MONEY
specialquantity SMALLINT
special_limit TINYINT Default=0
start_date DATETIME
end_date DATETIME
department SMALLINT Indexed
size VARCHAR(9)
tax SMALLINT
foodstamp TINYINT
scale TINYINT
scaleprice MONEY
mixmatchcode VARCHAR(13)
modified DATETIME
advertised TINYINT
tareweight DOUBLE
discount SMALLINT
discounttype TINYINT
line_item_discountable TINYINT Default=1
unitofmeasure VARCHAR(15)
wicable SMALLINT Default=0
qttyEnforced TINYINT
idEnforced TINYINT
cost MONEY
inUse TINYINT
numflag INT Default=0
subdept SMALLINT
deposit DOUBLE
local INT Default=0
store_id SMALLINT Default=0
default_vendor_id INT Default=0
current_origin_id INT Default=0
auto_par DOUBLE Default=0
price_rule_id INT Default=0
last_sold DATETIME
id INT PK Increment Default=0

Depends on:

  • products (table)

Use: Stores an older snapshot of products Easier to pull small bits of info from instead of restoring an entire DB backup

productUser

Name Type Info
upc VARCHAR(13) PK
description VARCHAR(255)
brand VARCHAR(255)
sizing VARCHAR(255)
photo VARCHAR(255)
long_text TEXT
enableOnline TINYINT
soldOut TINYINT Default=0

Depends on:

  • products (table)

Use: Longer product descriptions for use in online webstore

products

Name Type Info
upc VARCHAR(13) Indexed
description VARCHAR(30) Indexed
brand VARCHAR(30)
formatted_name VARCHAR(30)
normal_price MONEY
pricemethod SMALLINT
groupprice MONEY
quantity SMALLINT
special_price MONEY
specialpricemethod SMALLINT
specialgroupprice MONEY
specialquantity SMALLINT
special_limit TINYINT Default=0
start_date DATETIME
end_date DATETIME
department SMALLINT Indexed
size VARCHAR(9)
tax SMALLINT
foodstamp TINYINT
scale TINYINT
scaleprice MONEY
mixmatchcode VARCHAR(13)
modified DATETIME
advertised TINYINT
tareweight DOUBLE
discount SMALLINT
discounttype TINYINT
line_item_discountable TINYINT Default=1
unitofmeasure VARCHAR(15)
wicable SMALLINT Default=0
qttyEnforced TINYINT
idEnforced TINYINT
cost MONEY
inUse TINYINT
numflag INT Default=0
subdept SMALLINT
deposit DOUBLE
local INT Default=0
store_id SMALLINT Default=0
default_vendor_id INT Default=0
current_origin_id INT Default=0
auto_par DOUBLE Default=0
price_rule_id INT Default=0
last_sold DATETIME
id INT PK Increment Default=0

Use: This table lists items in the system.

upc is how items are identified. Regardless of whether it's an integer or a varchar, it should always have length 13. Whether or not to include check digits is up to the individual store.

id provides a unique row identifier, but upc should probably be unique too. If not, you'll have to add code to either let the cashier choose which matching record or to limit which records are pushed to the registers.

description is used for screen display, reporting, and receipts. formatted_name is an alternative that will be used instead of description if it has a non-NULL, non-empty value. brand and description are intended to be distinct fields for use in things like shelf tags and signage. formatted_name can be used to combine these two fields or otherwise create a standardized screen/receipt description containing extra information.

Pricing: When an item has pricemethod 0, the price is simply normal_price. If pricemethod is greater than 0, groupprice and quantity are used to calculate the price. There is variance here by implementation, but generally pricemethod 1 or 2 will yield the most obvious grouped pricing. Example: buy one, get the second 50% off normal_price => 1.00 pricemethod => 1 (or maybe 2) groupprice => 1.50 quantity => 2 If discounttype is greater than zero, the special* columns get used instead but otherwise behavior should be similar. The special_limit column puts a per-transaction limit on sale pricing with zero indicating no limit. With a limit of one, the first item will ring up using the special* columns and all subsequent items will use the normal pricing columns.

start_date and end_date indicate the start and end of a sale. The current register code does not check these to validate sales.

department and subdept are an item's department and subdepartment settings.

tax indicates if an item is taxable and at what rate

foodstamp indicates whether an item can be purchased using foodstamps

scale indicates whether an item should be sold by weight

scaleprice indicates what type of random-weight barcodes are used. Value zero means UPC-A where the last 4 digits contains price with max value $99.99. Value one means EAN-13 where the last 5 digits contain price with max value $999.99.

mixmatchcode relates to pricing when pricemethod is greater than zero. Items with the same mixmatchcode are considred equivalent when determining whether the customer has reached the required quantity.

modified [ideally] lists the last time a product was changed. Not all back end tools remember to update this and of course direct updates via SQL may forget too.

tareweight is a default tare for by weight items

discount indicates whether an item is eligible for percentage discounts on a whole transactions. Value 0 means exclude from discounts.

discounttype indicates if an item is on sale 0 => not on sale 1 => on sale for everyone 2 => on sale for members Values greater than 2 may be used, but results will vary based on whose code you're running

line_item_discount indicates whether an item is eligible for line item discounts. Value 0 means not eligible.

unitofmeasure might be used for screen display and receipt listings of quantity.

qttyEnforced forces the cashier to enter an explicit quantity when ringing up the item

idEnforced forces the cashier to enter the customer's date of birth. This flag should be set to the age required to purchase the product - e.g., 21 for alcohol in the US.

cost is the item's cost

isUse indicates whether the item is currently available for sale. Whether cashiers can bypass this setting probably varies by front end implementation.

local indicates whether the item is locally sourced.

deposit is a PLU. The product record with this UPC will be added to the transaction automatically when the item is rung.

default_vendor_id is the identifier (vendors.vendorID) for the vendor who typically supplies the product.

current_origin_id is the identifier (origins.originID) for the geographical location where the product is currently sourced from.

Other columns: size, advertised, wicable, and numflag have no current meaning on the front or back end. Or no current implementation. The meaning of idEnforced is pretty clear, but setting it won't do anything.

reasoncodes

Name Type Info
textStr VARCHAR(100)
mask INT PK Default=0

Depends on:

  • suspensions

Use: Reason code work in conjunction with suspended memberships. The mask here is a bitmask. This lets you tag the suspensions.reasonCode with multiple reasons in one field. Probably not the

scaleItems

Name Type Info
plu VARCHAR(13) PK
price MONEY
itemdesc VARCHAR(100)
exceptionprice MONEY
weight TINYINT Default=0
bycount TINYINT Default=0
tare FLOAT Default=0
shelflife SMALLINT Default=0
netWeight SMALLINT Default=0
text TEXT
reportingClass VARCHAR(6)
label INT
graphics INT
modified DATETIME

Use: This holds info for deli-scale items. It's formatted to match what the Hobart DataGateWeigh file wants to see in a CSV

shelftags

Name Type Info
id INT PK
upc VARCHAR(13) PK
description VARCHAR(30)
normal_price MONEY
brand VARCHAR(100)
sku VARCHAR(13)
size VARCHAR(50)
units INT
vendor VARCHAR(50)
pricePerUnit VARCHAR(50)
count TINYINT Default=1

Use: Data for generating shelf tag PDFs. id is used to segment sets into different PDF documents. An id maps to a buyer at WFC, but doesn't have to.

Size relates to an indivdual product. Units relates to a case. So a case of beer has 24 units, each with a size of 12 oz.

Count is used to print multiples of the same tag

subdepts

Name Type Info
subdept_no SMALLINT PK
subdept_name VARCHAR(30)
dept_ID SMALLINT

Depends on:

  • departments (table)

Use: A department may contain multiple subdepartments. In most implementations I've seen, invidual products can be tagged with a subdepartment, but that setting doesn't go into the final transaction log

superDeptEmails

Name Type Info
superID INT PK
emailAddress VARCHAR(255)

Depends on:

  • superdepts (table)

Use: Associating a person or people with a super department for the purpose of notifications.

There is one record per super department but the email_address field may contain multiple addresses in a comma-separated list or whatever your mail server understands.

superDeptNames

Name Type Info
superID INT PK
super_name VARCHAR(50)

Depends on:

  • departments (table)

Use: Super departments contain departments. For the sake of humans they have names. Those go here.

superMinIdView

View

Name Type Info
superID INT
dept_ID INT

View

Depends on:

  • superdepts

Use: This view exists solely because MySQL won't let me use a subquery in the FROM clause of a VIEW.

superdepts

Name Type Info
superID INT PK
dept_ID INT PK

Depends on:

  • departments (table)

Use: Super departments contain departments. A department may belong to multiple super departments, although every department has one "master" super department for the purpose of some reporting (by convention the one with the lowest superID).

This is just an extra level of granularity to group departments together when they're often all collected

suspension_history

Name Type Info
username VARCHAR(50)
postdate DATETIME
post TEXT
cardno INT
reasoncode INT

Depends on:

  • suspensions (table)

Use: This table just keeps a record of member accounts

suspensions

Name Type Info
cardno INT PK Default=0
type CHAR(1)
memtype1 INT
memtype2 VARCHAR(6)
suspDate DATETIME
reason TEXT
mailflag INT
discount INT
chargelimit MONEY
reasoncode INT

Depends on:

  • custdata (table)

Use: suspensions are a way of putting a membership on hold. When an account is suspended, it reverts to the lowest possible privileges and custdata's settings for Type, memType, Discount, and ChargeLimit are stored here in memtype1, memtype2, discount, and chargelimit (respectively). When the account is restored, custdata's original settings are repopulated from these saved values.

type currently contains 'I' (inactive memberships that may return) or 'T' (terminated memberships that will not return).

Historically, the "reason" field was used to manually enter a reason for the suspension. Using the reasoncode is now preferred. This field is interpretted as binary using masks from the reasoncodes table to determine which reason(s) have been given.

taxrates

Name Type Info
id INT PK
rate FLOAT
description VARCHAR(50)

Use: List of applicable tax rates. By convention, id 0 should be used for untaxed goods. Only one rate may be applied, so you may have more entries here than there are local tax rates

tenders

Name Type Info
TenderID SMALLINT PK
TenderCode VARCHAR(2) Indexed
TenderName VARCHAR(25)
TenderType VARCHAR(2)
ChangeMessage VARCHAR(25)
MinAmount MONEY Default=0.01
MaxAmount MONEY Default=1000
MaxRefund MONEY Default=1000
TenderModule VARCHAR(50) Default='TenderModule'

Use: List of tenders IT CORE accepts. TenderCode should be unique; it's what cashiers type in at the register as well as the identifier that eventually shows up in transaction logs.

ChangeMessage, MinAmount, MaxAmount, and MaxRefund all do exactly what they sound like.

TenderName shows up at the register screen and on various reports.

TenderType and TenderID are mostly ignored.

upcLike

Name Type Info
upc VARCHAR(13) PK
likeCode INT

Depends on:

  • likeCodes (table)

Use: Lists the items contained in each like code

usageStats

Name Type Info
usageID INT PK Increment
tdate DATETIME
pageName VARCHAR(100)
referrer VARCHAR(100)
userHash VARCHAR(40)
ipHash VARCHAR(40)

Use: Internal usage metrics. Tracks visits

vendorContact

Name Type Info
vendorID INT PK
phone VARCHAR(15)
fax VARCHAR(15)
email VARCHAR(50)
website VARCHAR(100)
notes TEXT

Use: Information about how to contact a vendor

vendorDeliveries

Name Type Info
vendorID INT PK
frequency VARCHAR(10)
regular TINYINT Default=1
nextDelivery DATETIME
nextNextDelivery DATETIME
sunday TINYINT Default=0
monday TINYINT Default=0
tuesday TINYINT Default=0
wednesday TINYINT Default=0
thursday TINYINT Default=0
friday TINYINT Default=0
saturday TINYINT Default=0

Use: Schedule of vendor deliveries

vendorDepartments

Name Type Info
vendorID INT PK
deptID INT PK
name VARCHAR(125)
margin FLOAT
testing FLOAT
posDeptID INT

Depends on:

  • vendors (table)

Use: This table contains a vendors product categorization. Two float fields, margin and testing, are provided so you can try out new margins (i.e., calculate SRPs) in testing without changing the current margin setting.

Traditional deptID corresponds to a UNFI's category number. This may differ for other vendors.

vendorItems

Name Type Info
vendorItemID INT Indexed Increment
upc VARCHAR(13) Indexed
sku VARCHAR(13) PK Indexed
brand VARCHAR(50)
description VARCHAR(50)
size VARCHAR(25)
units DOUBLE Default=1
cost MONEY
saleCost MONEY Default=0
vendorDept INT Default=0
vendorID INT PK Indexed
srp MONEY
modified datetime

Depends on:

  • vendors (table)
  • vendorDepartments (table)

Use: This table has items from vendors. Cost and vendor department margin are used to calculate SRPs, but the other fields are useful for making shelf tags.

Size relates to an indivdual product. Units relates to a case. So a case of beer has 24 units, each with a size of 12 oz.

Cost represents the unit cost. Cost times units should then equal the case cost. Sale Cost is for storing temporary special prices.

upc corresponds to products.upc. Multiple vendorItems records may map to one products record if an item is available from more than one vendor or under several SKUs from the one vendor. sku should uniquely identify an item for the purpose of ordering it from the vendor. If the vendor does not have SKUs you have to assign some. The field is wide enough to hold a UPC; putting your UPC or the vendor's UPC in the SKU field may be a simple solution to assigning SKUs.

vendorSKUtoPLU

Name Type Info
vendorID INT PK
sku VARCHAR(13) PK
upc VARCHAR(13) Indexed

Depends on:

  • vendors (table)
  • vendorItems (table)
  • products (table)

Use: Table mapping vendor SKUs to store UPCs. Most commonly used for bulk items sold by a PLU rather

vendorSRPs

Name Type Info
vendorID INT PK
upc VARCHAR(13) PK
srp MONEY

Depends on:

  • vendorItems (table)
  • vendorDepartments (table)

Use: This table contains SRPs for items from a given vendor.

This could be calculated as items are imported and stored in vendorItems, but in practice some vendor catalogs are really big. Calculating SRPs afterwards in a separate step reduces the chances of hitting a PHP time or memory limit.

vendors

Name Type Info
vendorID INT PK
vendorName VARCHAR(50)
vendorAbbreviation VARCHAR(10)
shippingMarkup DOUBLE Default=0
discountRate DOUBLE Default=0
phone VARCHAR(15)
fax VARCHAR(15)
email VARCHAR(50)
website VARCHAR(100)
notes TEXT
localOriginID INT Default=0

Use: List of known vendors. Pretty simple.

Clone this wiki locally