title: Which one should be preferred 1:1,0 or nullable fields on one table on relational database?
body: <p>I use Azure Sql and Entity-Framework Code First.</p>
  
  <p>I have <code>Transaction</code> Table. There are 4 types which are <code>buy/sell</code>, <code>withdrawal</code>, <code>deposit</code> and <code>fee</code>.</p>
  
  <p>For example, I need <code>DepositCode</code> for deposit transactions but this column will be null for others. Also I need <code>ItemPrice</code> and <code>ItemAmount</code> for buy/sell but it will be null for other types.</p>
  
  <p>Example <code>Transaction</code> Table</p>
  
  <pre><code> public class Transaction
      {
          public long Id { get; set; }
          public decimal Amount { get; set; }
          public int Type { get; set; }
          public string DepositCode { get; set; }
          public decimal? ItemPrice { get; set; }
          public decimal? ItemAmount { get; set; }
          public string WithdrawalIban { get; set; }
      }
  </code></pre>
  
  <p>or</p>
  
  <pre><code> public class Transaction
      {
          public long Id { get; set; }
          public decimal Amount { get; set; }
          public int Type { get; set; }
          public DepositTransaction DepositTransaction { get; set; }
          public WithdrawalTransaction BuyAndSellTransaction { get; set; }
          public WithdrawalTransaction WithdrawalTransaction { get;set; }
      }
  
  
   public class DepositTransaction
      {
          public long Id { get; set; }
          public Transaction Transaction { get; set; }
          public string DepositCode { get; set; }
      }
  
  
   public class WithdrawalTransaction
      {
          public long Id { get; set; }
          public Transaction Transaction { get; set; }
          public string WithdrawalIban { get; set; }
      }
  
  
   public class BuySellTransaction
      {
          public long Id { get; set; }
          public Transaction Transaction { get; set; }
          public decimal ItemPrice { get; set; }
          public decimal ItemAmount { get; set; }
      }
  
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;WithdrawalTransaction&gt;()
          .HasRequired(wt =&gt; wt.Transaction)
          .WithOptional(tr =&gt; tr.WithdrawalTransaction);
  
          modelBuilder.Entity&lt;DepositTransaction&gt;()
        .HasRequired(db =&gt; db.Transaction)
        .WithOptional(tr=&gt; tr.DepositTransaction);
  
          modelBuilder.Entity&lt;BuySellTransaction&gt;()
        .HasRequired(bs =&gt; bs.Transaction)
        .WithOptional(tr =&gt; tr.BuySellTransaction);
  
      }
  </code></pre>
  
  <p>Which one should be preferred ?</p>