foreign-keys Questions

6

Solved

Is it possible via script/tool to generate a delete statement based on the tables fk relations. i.e. I have the table: DelMe(ID) and there are 30 tables with fk references to its ID that I need to...
Tarrasa asked 27/1, 2009 at 22:20

3

Solved

I know that this question has already been asked, but I still can't find what I'm doing wrong. I'm using the framework Laravel. I have 2 tables (Users and Locations). When I want to create a User...
Stereoisomerism asked 20/12, 2013 at 14:14

4

Is it possible to make a ForeignKey to more than one model? I want to choose from different models like Parts and Machines Model. I read this to combine multiple models into one list: How to combin...
Exodontics asked 26/1, 2011 at 10:35

3

Solved

I create a table in mysql using the following script: CREATE TABLE IF NOT EXISTS users_x_activities( id int NOT NULL auto_increment, id_user int unsigned NOT NULL, id_attivita int unsigned NO...
Gertrude asked 26/7, 2013 at 20:26

8

Solved

I use ON DELETE CASCADE regularly but I never use ON UPDATE CASCADE as I am not so sure in what situation it will be useful. For the sake of discussion let see some code. CREATE TABLE parent ( id ...
Implied asked 26/9, 2009 at 15:41

11

Solved

I'm working on adding Django 2.0 support to the django-pagetree library. During automated testing, using an sqlite in-memory database, I'm getting a bunch of errors like this: File "/home/nnyby/s...
Tracee asked 3/12, 2017 at 16:25

7

Solved

When I run a mysqldump command on my database and then try to import it, it fails as it attempts to create the tables alphabetically, even though they may have a foreign key that references a table...
Featherston asked 12/3, 2010 at 0:17

16

Solved

When setting up foreign keys in SQL Server, under what circumstances should you have it cascade on delete or update, and what is the reasoning behind it? This probably applies to other databases a...
Wiper asked 12/9, 2008 at 15:27

5

Solved

Say I have two tables, user and comment. They have table definitions that look like this: CREATE TABLE `user` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `username` VARCHAR(255) NOT NULL, `deleted`...
Angloirish asked 16/8, 2010 at 10:57

5

Solved

I am trying to create a table with a varchar column as foreign key but MySql gives me an error while creating the table. My query is like this: CREATE TABLE network_classes ( id TINYINT(1) UNSIGN...
Bullet asked 22/8, 2013 at 14:23

2

Solved

In an ERD, a weak/non-identifying relationship is one that connects two strong entities, and is indicated with a dashed line. A strong/identifying relationship is one that connects a strong entity ...

5

Solved

On our original design we screwed up a foreign key constraint in our table. Now that the table is full of data we cannot change it without dropping all of the records in the table. The only solutio...
Consume asked 17/5, 2011 at 15:26

17

Solved

If I want to delete all the tables in my database like this, will it take care of the foreign key constraint? If not, how do I take care of that first? GO IF OBJECT_ID('dbo.[Course]','U') IS NOT N...
Wellread asked 21/11, 2009 at 17:15

4

Solved

I have existing table objects with data. Now I need to add new table named holdings and add a relation from objects to holdings table. In the migration file, I print this: $table->foreign('hold...
Corsiglia asked 25/6, 2017 at 8:49

3

Solved

Here I have a model called Staff which has OneToOne relation with django User model and ForeignKey relation to the Organization model.Here while deleting the organization I want to check if the org...
Blithesome asked 17/9, 2019 at 10:36

15

Solved

Essentially, I am having the same issue as this guy, minus the table prefix. Because I have no table prefix, his fix does not work. http://forums.laravel.com/viewtopic.php?id=972 I am trying to bu...
Permissible asked 10/8, 2012 at 1:23

4

Solved

Is there an option in the django admin view for ordering of foreign key fields? i.e. I have a foreign key to a "School" model, which shows as a dropdown, sorted on pk-- I would like it to be sorted...
Danielson asked 24/1, 2012 at 19:30

9

Solved

How can I change the display text in a <select> field while selecting a field which is a ForeignKey? I need to display not only the name of ForeignKey, but also the name of its parent.
Androgyne asked 26/7, 2011 at 21:18

3

Solved

In Django, is there any way to set a foreign key to a field of another model? For example, imagine I have a ValidationRule object. And I want the rule to define what field in another model is to be...
Rubble asked 8/4, 2009 at 14:12

4

Solved

Would the following SQL statement automatically create an index on Table1.Table1Column, or must one be explicitly created? Database engine is SQL Server 2000 CREATE TABLE [Table1] ( . . . CONST...
Reparative asked 10/11, 2008 at 20:1

16

Solved

In MySQL, how do I get a list of all foreign key constraints pointing to a particular table? a particular column? This is the same thing as this Oracle question, but for MySQL.
Lusatian asked 14/10, 2008 at 15:18

7

Solved

I have a backup script for my MySQL database, using mysqldump with the --tab option so it produces a .sql file for the structure and a .txt file (pipe-separated) for the content. Some tables have ...
Ardennes asked 11/4, 2013 at 0:20

9

I have a table whose primary key is referenced in several other tables as a foreign key. For example: CREATE TABLE `X` ( `X_id` int NOT NULL auto_increment, `name` varchar(255) NOT NULL, PRIMA...
Grimsby asked 30/4, 2009 at 13:45

12

Solved

I want to remove constraints from my table. My query is: ALTER TABLE `tbl_magazine_issue` DROP CONSTRAINT `FK_tbl_magazine_issue_mst_users` But I got an error: #1064 - You have an error in y...
Masked asked 2/1, 2013 at 12:27

3

Solved

Using migrations, I need to add a new field (a foreign key) to a model. I know it can be done with: migrations.AddField( model_name='MyModel', name='state', field=models.ForeignKey(null=True, ...
Thong asked 29/3, 2016 at 9:24

© 2022 - 2024 — McMap. All rights reserved.