Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 716973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:21:35+00:00 2026-05-14T05:21:35+00:00

I have two tables: info: ID, fee_id and fee: ID, amount and a reference

  • 0

I have two tables:

info: ID, fee_id

and

fee: ID, amount

and a reference between them (SQL Server 2008):

ALTER TABLE info WITH CHECK ADD CONSTRAINT FK_info_fee FOREIGN KEY(fee_id)
REFERENCES fee (ID)
ALTER TABLE info CHECK CONSTRAINT FK_info_fee
GO

How to configure this reference that way so a record in fee will be deleted if info.fee_id becomes NULL

EDIT: or maybe set info.fee_id to NULL on deleting the corresponding record in fee.

Anyway I can do it this way:

UPDATE info SET fee = NULL WHERE = ..
DELETE FROM fee WHERE ..

but I’m sure that this can be done by the database itself.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:21:35+00:00Added an answer on May 14, 2026 at 5:21 am

    Some thoughts:

    • If you have a one:one reference then can the 2 tables be combined?
    • Drilling up from child to parent is odd: if it’s 1:1 then can you reverse the FK direction and simply CASCADE NULL?
    • Otherwise, you’ll have to use a trigger but assuming 1:1 makes me uneasy…
    • … unless you have a unique constraint/index on info_fee.fee_id

    Like so:

    ALTER TABLE info WITH CHECK ADD
    CONSTRAINT FK_fee_info_fee FOREIGN KEY (id) REFERENCES info_fee (fee_ID) ON DELETE SET NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a two table's ,where i have to dump the info into the
I have two tables: locations and listings. locations id title address latitude longitude listings
I have a SQL query and it fails at times. That means that query
I have a query like the following that returns the correct number of rows
Morning, I'm having some trouble creating tables/loading fixtures. (symfony 1.4.6 with the bundled Doctrine
Is it possible to generate a schema of a database from nHibernate, where I
I'm trying to figure out how to write a statement in my first CI
I started creating JPA/hibernate mappings for a legacy database based on Oracle. At one
I realise that the answer to these types of questions are often it depends
SELECT b.categoryid, SUM(viewcount) AS cnt, categoryname FROM bookvisit AS bv INNER JOIN book AS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.