# Database Relationship and Foreign Key Errors in Base44

Your Base44 app uses related database tables (for example, a Users table linked to an Orders table), but the relationships are not working correctly. Related records don't appear in linked views, creating a record in one table doesn't properly reference the related record in another, or deleting a record causes unexpected cascade effects.

This issue often manifests as dropdown selectors for related records showing empty lists, detail pages failing to display linked data, or errors when trying to create records that reference other tables.

Relationship issues can be subtle and may only appear with certain data combinations or when the related tables grow beyond a small number of records.

## Error Messages You Might See

- Referenced record not found
- Foreign key constraint violation
- Cannot delete record: referenced by other records

[Referenced record not found](/content/guides/search?q=Referenced%20record%20not%20found "Search for this error"/index.html)  
[Foreign key constraint violation](/content/guides/search?q=Foreign%20key%20constraint%20violation "Search for this error"/index.html)  
[Cannot delete record: referenced by other records](/content/guides/search?q=Cannot%20delete%20record:%20referenced%20by%20other%20records "Search for this error"/index.html)

## Common Causes

1. The relationship field type is incorrectly configured (e.g., using a text field instead of a proper reference/relation field)
2. The referenced record was deleted but the foreign key reference still exists, creating orphaned records
3. The relationship direction is inverted: the link field is on the wrong table
4. The relation field references the wrong column (e.g., referencing a name field instead of the unique ID)

## How to Fix It

Review your table schemas and ensure that relationship fields use Base44's proper **relation/reference field type**, not a plain text or number field storing IDs manually. The built-in relation type handles the linking automatically.

Check the direction of the relationship: a one-to-many relationship (e.g., one User has many Orders) requires the link field on the "many" side (Orders), not on the "one" side (Users).

For existing apps with broken relationships and orphaned records, a developer can help clean up the data and reconfigure the schema correctly without losing existing records.

## Frequently Asked Questions

### Why don't my linked records show up in Base44?

Make sure you're using Base44's relation field type, not a plain text field. The relation field type automatically handles the linking and display of related records.

### How do I fix orphaned records in Base44?

Orphaned records occur when a referenced record is deleted. You may need to clean up the orphaned references manually or set up cascade rules to handle deletions automatically.
