title: How to create column which is generated automatically in relation to primary key which is the foreign key fro
body: <p>In SQL Server Management Studio, I am creating this table:</p>
  
  <pre><code>CREATE TABLE Purchase 
  (
       PurchaseID INT NOT NULL 
           FOREIGN KEY REFERENCES Product(ProductID) PRIMARY KEY,
       TotalQuantity INT NOT NULL,
       Price AS (PurchaseID.PRICE), 
       TotalPrice AS (TotalQuantity*Price),
       SalesAssistantID INT NOT NULL 
           FOREIGN KEY REFERENCES SalesAssistant(SalesAssistantID), 
       CashierID INT NOT NULL 
           FOREIGN KEY REFERENCES Cashier(CashierID)
  )
  </code></pre>
  
  <p>Above code only represents what I want to achieve (<code>Price AS (PurchaseID.PRICE)</code>), <code>Price</code> should be created whenever the <code>PurchaseID</code> is specified so that <code>TotalCost</code> can also function automatically, I could not solve this problem. How to do it?   </p>