Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Foreign Keys

Featured Replies

HI

I have a problem with Foriegn Keys, ive been trying to work it out now for over a week. Ive watched Tutorials after Tutorials, copied what they have said but its not working. And its only a simple Database with 2 Tables which require a FK join. I have 2 tables as shown below:

CustomerData (parent table)

ID

Name

Address

Email

PhoneNumber

MobileNumber

Country

City

Password

 

PetData (child table)

CustomerID --foreign key linked to ID form parent table

Type

Breed

Age

Colour

Price

SalesPoint

Description

Image1

Image2

 

But i just cannot get it to work i keep getting this error: Cannot add or update a child row: a foreign key constraint fails (`petseen`.`petdata`, CONSTRAINT `petdata_ibfk_1` FOREIGN KEY (`CustomerID`) REFERENCES `customerdata` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE)

 

I need the customer to be able to upload as many pet ads as they wish.

 

any help would be great and many thanks.

Just to double-check - you ARE updating CustomerData first, right?

 

What's the query?

Edited by Renaissance-Design

You're probably supplying petData with a CustomerID which doesn't exist in CustomerData.

Have you already got data in the petdata table which may contradict the constraint? That's usually where the issue lies if everything else looks ok!

 

Keith

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.