简体   繁体   中英

Nesting Tables in SQL Server Express

I am creating a purchase order system where someone can store details of their purchase. So I created a database, with tables for supplier information from which we will buy stuff and another table where we store what we are buying.

In the PurchaseOrder table, there are columns for :

  • PurchaseOrderNo (Primary)
  • BuyerInitials
  • DateOfPurchase
  • ProjectCode
  • Items (linking to the PurchaseItems table)

I want to add another column with Items' details, so I created another table PurchaseItems which has the following columns:

  • PurchaseOrderNo. (this would be repeat for each part)
  • PartNo
  • Description
  • Quantity
  • UnitAmount
  • VATAmount
  • TotalAmount

Logically it seems simple, but I can't seem to get my head around on how I would link the tables. Thank you very much for the help :)

Create a seperate table say OrderedItems which maps the PartNo and PurchaseOrderNo. This avoids the repetition of PurchaseOrderNo in each row and also maintains the relation between PurchaseOrder and PurchaseItems table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM