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

  • SEARCH
  • Home
  • 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 6627741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:02:58+00:00 2026-05-25T22:02:58+00:00

This is ms create table script: It is a N:M relation between the SchoolclassCode

  • 0

This is ms create table script:

It is a N:M relation between the SchoolclassCode and the Pupil table

CREATE TABLE Schoolclasscode (
  schoolclassId    integer PRIMARY KEY AUTOINCREMENT NOT NULL 
);

CREATE TABLE SchoolclasscodePupil (
  pupilId_FK        integer NOT NULL,
  schoolclassId_FK  integer NOT NULL,
  /* Foreign keys */
  FOREIGN KEY (schoolclassId_FK)
    REFERENCES Schoolclasscode(schoolclassId)
    ON DELETE CASCADE
    ON UPDATE NO ACTION, 
  FOREIGN KEY (pupilId_FK)
    REFERENCES pupil(pupilId)
    ON DELETE CASCADE
    ON UPDATE NO ACTION
);

CREATE TABLE pupil (
  pupilId           integer PRIMARY KEY AUTOINCREMENT NOT NULL  
);

When I delete a SchoolclassCode object in my code:

public void DeleteSchoolclass(int schoolclassCodeID, SQLiteConnection con)
        {
            using (SQLiteCommand com = new SQLiteCommand(con))
            {
                com.CommandText = "DELETE FROM schoolclasscode WHERE SchoolclassId = @SchoolclassId";
                com.Parameters.Add(new SQLiteParameter("@SchoolclassId", schoolclassCodeID));
                com.ExecuteNonQuery(); 
            }
        }

The entry in the schoolclasscode table is deleted. But nothing more. I can even additionally delete the schoolclasscodeId_FK in the SchoolclasscodePupil but no pupils were deleted by a cascade delete constraint.

What do I wrong?

  • 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-25T22:02:59+00:00Added an answer on May 25, 2026 at 10:02 pm

    In an N:M relation, either N or M may be zero. Referential integrity has not been violated.

    Deleting a class will deregister all pupils from that class. Similarly deleting a pupil will unroll them from all classes. But deleting a pupil can never cause a cascade to cancel a class, nor can deleting a class expel a pupil. Even if it’s the last class the pupil was taking, you’re left with a pupil who has zero classes, which is valid under the referential integrity rules.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this: create table account ( id int identity(1,1) primary key,
Query was this: CREATE TABLE `query` ( `id` int(11) NOT NULL auto_increment, `searchquery` varchar(255)
I have a table similar to this: CREATE TABLE example ( id integer primary
I have a table that's created like this: CREATE TABLE bin_test (id INTEGER PRIMARY
Given a table structure like this: CREATE TABLE `user` ( `id` int(10) unsigned NOT
If my table looks like this: CREATE TABLE `daily_individual_tracking` ( `daily_individual_tracking_id` int(10) unsigned NOT
I want to do something like this: create table app_users ( app_user_id smallint(6) not
For example, say I have this SQL Script: create table Person ( id int
I have a script in T-SQL that goes like this: create table TableName (...)
I have a table papers CREATE TABLE `papers` ( `id` int(11) NOT NULL AUTO_INCREMENT,

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.