According to your explanation, suppose you have two tables in your sql database called
Transaction
and
TransactionItemWise
. Transaction table stores any transaction as a summary and TransactionItemWise table keeps them itemwise. That means there is
1:M relationship
between Transaction and TransactionItemWise tabels. So as we know
1
side key goes to
M
side. See the example below
CREATE TABLE Transaction(
TrxID varchar(3),
TotAmount float,
TotQty int,
TrxDate DateTime,
CONSTRAINT pk_Transaction PRIMARY KEY (TrxID)
)
CREATE TABLE TransactionItemWise(
TrxID varchar(3),
ItemNo varchar(3),
ItemAmount float,
ItemQty int,
CONSTRAINT pk_TransactionItemWise PRIMARY KEY (TrxID,ItemNo),
CONSTRAINT fk_PerOrders FOREIGN KEY (TrxID)
REFERENCES Transaction(TrxID)
)