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 8860023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:11:22+00:00 2026-06-14T15:11:22+00:00

I have 3 tables player , goal , card how should i build my

  • 0

I have 3 tables

player, goal, card

how should i build my database so it automatically deletes goal and card row containing player id?

my declarations of tables i suppose i should add on delete cascade but i don’t understand it very well so can any of you help me?

CREATE TABLE IF NOT EXISTS `#__footsal_players` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,

`ordering` INT(11)  NOT NULL ,
`state` TINYINT(1)  NOT NULL DEFAULT '1',
`checked_out` INT(11)  NOT NULL ,
`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` INT(11)  NOT NULL ,
`id_team` INT(11)  NOT NULL ,
`first_name` varchar(255)  NOT NULL ,
`last_name` varchar(255)  NOT NULL ,
`birth_date` DATE  NOT NULL DEFAULT '0000-00-00',
`email` varchar(255)  NOT NULL ,

 PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT COLLATE=utf8_polish_ci

CREATE TABLE IF NOT EXISTS `#__footsal_goals` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,

`state` TINYINT(1)  NOT NULL DEFAULT '1',
`checked_out` INT(11)  NOT NULL ,
`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` INT(11)  NOT NULL ,
`id_player` INT(11)  NOT NULL ,
`id_resault` INT(11)  NOT NULL ,
`id_game` INT(11) NOT NULL ,
`goals_number` VARCHAR(255)  NOT NULL ,
`id_session` VARCHAR(11)  NOT NULL ,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT COLLATE=utf8_polish_ci;


CREATE TABLE IF NOT EXISTS `#__footsal_yellow_cards` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,

`state` TINYINT(1)  NOT NULL DEFAULT '1',
`checked_out` INT(11)  NOT NULL ,
`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` INT(11)  NOT NULL ,
`id_player` INT(11)  NOT NULL ,
`id_game` INT(11) NOT NULL ,
`id_resault` INT(11)  NOT NULL ,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT COLLATE=utf8_polish_ci;
  • 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-06-14T15:11:22+00:00Added an answer on June 14, 2026 at 3:11 pm

    I don’t have MySQL running atm, but code below should work for goals. The idea is that when you define the foreign key, you assign delete and update rules. These apply when the primary key (id in player) is modified. So when the primary key in player is deleted (i.e. the player is deleted), the rows with corresponding foreign keys, behave according to their rule. Cascade means ‘follow’, so in this case delete it too.

    CREATE TABLE IF NOT EXISTS `#__footsal_goals` (
    `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    
    `state` TINYINT(1)  NOT NULL DEFAULT '1',
    `checked_out` INT(11)  NOT NULL ,
    `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
    `created_by` INT(11)  NOT NULL ,
    `id_player` INT(11)  NOT NULL ,
    `id_resault` INT(11)  NOT NULL ,
    `id_game` INT(11) NOT NULL ,
    `goals_number` VARCHAR(255)  NOT NULL ,
    `id_session` VARCHAR(11)  NOT NULL ,
    PRIMARY KEY (`id`),
    FOREIGN KEY goals_player_fk (`id_player`) 
    REFERENCES `#__footsal_players` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
    ) ENGINE=InnoDB DEFAULT COLLATE=utf8_polish_ci;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small MS Access database containing four tables and are struggeling with
I have two tables in the database Team:Id(int PK), Name(nvarchar) and Player:Id(int PK), Name(nvarchar),
I have 3 tables, team(id,name) player(id,teamid,name) playerdetail(id,playerid,height,weight), the relationship between team and player is
I have a tables 'players' and 'awards'. I have some duplicate player entries that
I have a very simple database consisting of these tables. Here I am trying
so i have 2 tables: -char (keeps information about the player) -special (its a
I have two tables: Team: teamId, teamName Player: playerId, teamId, playerName I want to
I have two tables: Person (personID, name, address, phone, email) Player (dateOfBirth, school) What
I have two tables that have a many-many relationship: Player(personID, school) Team(teamID, name) What
I have 2 tables in the database BRAND - id - name PRODUCT -

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.