DATABASE WIKI

D1: gfs-netsuite · 3818ecd5-995e-4694-a08b-a273c94291da · ENAM/EWR
185,487 ROWS
18
Tables
~120
Columns
22
Indexes
29.6 MB
DB Size

Entity Tables

customers 283 rows

Customer master records — companies GFS sells to
ColumnTypeNullableDefaultDescription
idINTEGERNoNetSuite internal ID (PK)
companynameTEXTNoCompany display name
entityidTEXTYesNS entity ID string
emailTEXTYesPrimary email
phoneTEXTYesPrimary phone
faxTEXTYesFax number
termsINTEGERYesFK → ref_terms.id
salesrepINTEGERYesFK → employees.id
categoryINTEGERYesFK → ref_categories.id
creditlimitREALYesCredit limit ($)
ispersonTEXTYes'F'T=individual, F=company
datecreatedTEXTYesM/D/YYYY format
lastmodifieddateTEXTYesM/D/YYYY format
Indexes: idx_customers_name (companyname) · idx_customers_salesrep (salesrep)

vendors 484 rows

Vendor/supplier master records
ColumnTypeNullableDefaultDescription
idINTEGERNoNetSuite internal ID (PK)
companynameTEXTNoCompany display name
entityidTEXTYesNS entity ID string
emailTEXTYesPrimary email
phoneTEXTYesPrimary phone
termsINTEGERYesFK → ref_terms.id
creditlimitREALYesCredit limit ($)
is1099eligibleTEXTYes'F'T=1099 eligible
taxidnumTEXTYesTax ID / EIN
datecreatedTEXTYesM/D/YYYY
lastmodifieddateTEXTYesM/D/YYYY
isinactiveTEXTYes'F'T=inactive
Index: idx_vendors_name (companyname)

items 1,265 rows 114 inactive

Product/item master — includes 14 allergen flags
ColumnTypeNullableDefaultDescription
idINTEGERNoNetSuite internal ID (PK)
itemidTEXTNoItem name/number (e.g. PUB6000)
displaynameTEXTYesFull display name
itemtypeTEXTYesInvtPart, Assembly, Kit, NonInvtPart
classINTEGERYesFK → ref_classes.id
departmentINTEGERYesFK → ref_departments.id (= brand)
upccodeTEXTYesUPC barcode
averagecostREALYesWeighted avg cost ($)
costREALYesLast purchase cost ($)
isinactiveTEXTYes'F'T=inactive
custitem1INTEGERYesCustom field 1
custitem3TEXTYesCustom field 3
custitem4TEXTYesCustom field 4
custitem6TEXTYesCustom field 6
14 ALLERGEN FLAGS (all TEXT, default 'F', T=contains):
custitem_as_milk · custitem_as_eggs · custitem_as_peanuts · custitem_as_soybeans · custitem_as_wheat · custitem_as_fish · custitem_as_tree_nuts · custitem_as_crustacean · custitem_as_celery · custitem_as_lupin · custitem_as_molluscs · custitem_as_mustard · custitem_as_sesame · custitem_as_sulphur_dioxide
Indexes: idx_items_itemid · idx_items_type (itemtype) · idx_items_dept (department)

contacts 490 rows

People at customer/vendor companies
ColumnTypeDescription
idINTEGER PKNS internal ID
firstnameTEXTFirst name
lastnameTEXTLast name
emailTEXTEmail
phoneTEXTPhone
titleTEXTJob title
companyINTEGERFK → customers.id or vendors.id
company_nameTEXTDenormalized company name
isinactiveTEXTT=inactive (default F)
Index: idx_contacts_company

employees 116 rows

GFS staff — sales reps, managers, operations
ColumnTypeDescription
idINTEGER PKNS internal ID
entityidTEXTEmployee ID string
firstname, lastnameTEXTName
emailTEXTEmail
titleTEXTJob title
phoneTEXTPhone
departmentINTEGERFK → ref_departments.id
classINTEGERFK → ref_classes.id
locationINTEGERFK → ref_locations.id
supervisorINTEGERFK → employees.id
isinactiveTEXTT=inactive (default F)
issalesrepTEXTT=sales rep (default F)
issupportrepTEXTT=support rep (default F)
hiredate, releasedateTEXTM/D/YYYY
giveaccessTEXTT=has NS login (default F)

Transaction Tables

transactions 102,367 rows

All transaction headers — 20 types spanning 2018-2027
ColumnTypeNullableDefaultDescription
idINTEGERNoNetSuite internal ID (PK)
tranidTEXTYesDocument number (e.g. "12425")
trandateTEXTNoDate in M/D/YYYY format
typeTEXTNoTransaction type code (see below)
entityINTEGERYesFK → customers.id or vendors.id (backfilled)
entity_nameTEXTYesDenormalized entity name
foreigntotalREALYesTotal amount ($). Invoices positive, bills positive.
statusTEXTYesStatus code (varies by type)
duedateTEXTYesPayment due date M/D/YYYY
shipdateTEXTYesShip date M/D/YYYY
memoTEXTYesTransaction memo
yearINTEGERGENERATEDSTORED: extracted from trandate (last 4 chars)
Indexes: idx_txn_type · idx_txn_date · idx_txn_entity · idx_txn_type_date (composite) · idx_txn_year

Transaction Type Codes (20)

CodeNameCount$ ValueEntity?Statuses
CustInvcCustomer Invoice12,542$169.8MYesA=Open, B=Paid
SalesOrdSales Order12,862$177.4MYesB=Pending, D=Partial, F=PendBill, G=Billed, H=Closed
VendBillVendor Bill22,916$145.0MYesA=Open, B=Paid, C=Cancelled
PurchOrdPurchase Order11,566$131.0MYesB=PendRcpt, D=Partial, E=PendBill/Partial, F=PendBill, G=Billed, H=Closed
CustPymtCustomer Payment8,195$163.2MYesB=NotDeposited, C=Deposited
VendPymtVendor Payment9,603$144.0MYes
ItemShipItem Fulfillment12,375No
CheckCheck5,493$29.1MYes
ItemRcptItem Receipt3,491$51.7MNo
CustCredCredit Memo932$2.7MYes
InvAdjstInventory Adjustment848$5.95MNo*
WorkOrdWork Order54775%
InvWkshtInventory Worksheet457$43.5MNo
DepositDeposit220$9.25MNo
VendCredVendor Credit116$254KYes
BuildAssembly Build98$107KNo
JournalJournal Entry47No
InvTrnfrInventory Transfer44No
UnbuildAssembly Unbuild13$4.2KNo
CustRfndCustomer Refund2$43.4KYes

Line Item Tables

invoice_lines 28,528 rows

CustInvc line items · 100% coverage
ColumnTypeDescription
idINTEGER PKAuto-increment
txn_idINTEGERFK → transactions.id
tranidTEXTInvoice number
trandateTEXTM/D/YYYY
customerTEXTCustomer name
itemINTEGERFK → items.id
item_nameTEXTDenormalized item name
quantityREALQty (negative = credit to rev)
rateREALUnit price ($)
netamountREALLine total (negative = revenue)
yearINTEGERYear extracted
Use ABS() for revenue queries. Avg 2.27 lines/invoice.

so_lines 29,098 rows

SalesOrd line items · 100% coverage · avg 2.26 lines/order
ColumnTypeDescription
idINTEGER PKAuto-increment
txn_idINTEGERFK → transactions.id
tranidTEXTSO number
trandateTEXTM/D/YYYY
customerTEXTCustomer name (denormalized)
itemINTEGERFK → items.id
item_nameTEXTItem display name
quantityREALQty ordered
rateREALUnit price ($)
netamountREALLine total
yearINTEGERYear extracted
Indexes: idx_solines_txn · idx_solines_item

vb_lines 21,317 rows 100%

VendBill line items · 11,631 bills with items · 11,285 expense-only bills have no lines by design
ColumnTypeDescription
idINTEGER PKAuto-increment
txn_idINTEGERFK → transactions.id
tranidTEXTBill number
trandateTEXTM/D/YYYY
vendorTEXTVendor name (NOT "customer" — different from invoice/so_lines)
itemINTEGERFK → items.id
item_nameTEXTItem display name
quantityREALQty received/billed
rateREALUnit cost ($)
netamountREALLine total
yearINTEGERYear extracted
Indexes: idx_vblines_txn · idx_vblines_item. Expense-only vendors (Tc's Trucking, Linecor, GoGreen, Daya, Cintas, AmEx, Uline) have VendBill headers but no item lines.

Financial Tables

gl_accounts 152 rows

Complete Chart of Accounts
ColumnTypeDescription
idINTEGER PKNS internal ID
acctnumberTEXTAccount number (1101, 4000, etc.)
fullnameTEXTFull account name
accttypeTEXTBank, AcctRec, AcctPay, OthCurrAsset, FixedAsset, OthCurrLiab, Equity, Income, COGS, Expense, OthIncome, OthExpense, NonPosting
balanceREALCurrent balance ($). NULL for NonPosting.
isinactiveTEXTT=inactive (default F)
102 P&L accounts (Income/COGS/Expense/OthIncome/OthExpense). Loaded from NS live data.

customer_pricing 1,264 rows

Customer-specific item pricing
ColumnTypeDescription
idINTEGER PKAuto-increment
customer_idINTEGERFK → customers.id
customerTEXTCustomer name
item_idINTEGERFK → items.id
item_nameTEXTItem name
priceREALCustomer price ($)
levelINTEGERPrice level
currencyINTEGERCurrency ID
Indexes: idx_pricing_cust · idx_pricing_item

Reference & Meta Tables

ref_terms 18

Payment terms
Due on receipt · Net 7 · Net 10 · Net 14 · Net 15 · Net 21 · Net 30 · Net 45 · Net 60 · Net 90 · Net 120 · 1% 10 Net 30 · 2% 10 Net 14 · 2% 10 Net 21 · 2% 10 Net 30 · 2% 14 Net 30 · 2% 15 Net 30 · Wire Pre Payment Required

ref_departments 14

Brands (= department in NS)
Alfresco Italian Specialties · Bentley's Bake Shope · Branson's Roadhouse BBQ · Brownstones Pizza · Components · Cornerstone Bakery · Food Broker · Global Food Solutions · Harvest Promise · Other · Power Up Meals · Right Start Foods · Smart Starts NY · Tiajuana Tortilla

ref_classes 6

Product classification
Frozen · Dry Grocery · Refrigerated · Packaging · Shipping · Other

ref_locations 17

Warehouses & facilities
Fairfield Warehouse · Linden Warehouse · Wyckoff Warehouse · Corporate HQ · NJ Satellite · LineCor · FOB Pickup · Superior Pack · Stellar Pak · Harvest Bakery · Meal Packing · Arias Mountain · Hayes Distribution · Mivila Calverton · Driscoll Foods · GFS Delta Pak · Quaker Sugar

ref_categories 14

Customer categories
Distributor · School District Direct · General Food Service · Food Manufacturer · Managment Company · Food Broker · School District · Healthcare · Co-Packing · Internal · E-Commerce · Migrant Feeding · Commissary · School

ref_shipping 7

Shipping methods
Airborne · Fedex Next Day · UPS Ground · Common Carrier · LineCor Distribution · FOB Customer Pickup · Vendor Delivery

Example Queries (D1 SQLite)

Revenue & Sales

-- Top 10 customers by 2026 revenue
SELECT entity_name, COUNT(*) as invs,
  ROUND(SUM(foreigntotal),2) as revenue
FROM transactions
WHERE type='CustInvc' AND year=2026
GROUP BY entity_name
ORDER BY revenue DESC LIMIT 10
-- Monthly revenue trend
SELECT year,
  CAST(SUBSTR(trandate,1,INSTR(trandate,'/')-1) AS INT) as month,
  COUNT(*) as inv_count,
  ROUND(SUM(foreigntotal),2) as revenue
FROM transactions
WHERE type='CustInvc' AND year>=2024
GROUP BY year, month ORDER BY year, month
-- Open sales orders
SELECT tranid, entity_name, foreigntotal, status
FROM transactions
WHERE type='SalesOrd'
  AND status IN ('A','B','D','E','F')
ORDER BY foreigntotal DESC

AR & Collections

-- Open AR by customer
SELECT entity_name, COUNT(*) as inv_count,
  ROUND(SUM(foreigntotal),2) as open_ar
FROM transactions
WHERE type='CustInvc' AND status='A'
GROUP BY entity_name
ORDER BY open_ar DESC
-- Top items by revenue (2026)
SELECT item_name,
  ROUND(SUM(ABS(netamount)),2) as revenue,
  ROUND(SUM(ABS(quantity)),2) as qty
FROM invoice_lines WHERE year=2026
GROUP BY item_name
ORDER BY revenue DESC LIMIT 20
-- Vendor spend analysis
SELECT entity_name,
  COUNT(*) as bills,
  ROUND(SUM(ABS(foreigntotal)),2) as spend
FROM transactions
WHERE type='VendBill' AND year=2026
GROUP BY entity_name
ORDER BY spend DESC LIMIT 10

sync_log 49+ rows

ETL sync tracking — one row per Worker cron execution
ColumnTypeDescription
idINTEGER PKAuto-increment
sync_typeTEXT'scheduled' or 'manual'
started_atTEXTISO 8601 timestamp
completed_atTEXTISO 8601 timestamp
records_syncedINTEGERRecords updated (default 0)
statusTEXT'running', 'success', 'error'
errorTEXTError message if failed

Foreign Key Relationships

customers.terms          → ref_terms.id
customers.salesrep       → employees.id
customers.category       → ref_categories.id
vendors.terms            → ref_terms.id
items.class              → ref_classes.id
items.department         → ref_departments.id       (= brand)
contacts.company         → customers.id | vendors.id
employees.department     → ref_departments.id
employees.class          → ref_classes.id
employees.location       → ref_locations.id
employees.supervisor     → employees.id             (self-ref)
transactions.entity      → customers.id | vendors.id (backfilled 78,616 rows)
invoice_lines.txn_id     → transactions.id
invoice_lines.item       → items.id
so_lines.txn_id          → transactions.id
so_lines.item            → items.id
vb_lines.txn_id          → transactions.id
vb_lines.item            → items.id
customer_pricing.customer_id → customers.id
customer_pricing.item_id     → items.id

Date Format Reference

All dates in D1 are stored as TEXT in M/D/YYYY format (e.g., "5/19/2026"). The year column on transactions is a GENERATED STORED column: CAST(SUBSTR(trandate, -4) AS INTEGER).
SQLite date parsingSUBSTR(trandate,-4) || '-' || SUBSTR('0'||SUBSTR(trandate,1,INSTR(trandate,'/')-1),-2) || '-' || ...
julianday() compatibleYes, after reformatting to YYYY-MM-DD
Month extractionCAST(SUBSTR(trandate, 1, INSTR(trandate, '/') - 1) AS INTEGER)