foreign-key-relationship Questions
8
Solved
I have a database with schema public and schema_A. I need to create a new schema schema_b with the same structure than schema_a.
I found the function below, the problem is that it does not copy th...
Sleepyhead asked 13/8, 2013 at 18:25
14
Solved
I need to make some changes to a SQL Server 2008 database.
This requires the creation of a new table, and inserting a foreign key in the new table that references the Primary key of an already ex...
Dislocate asked 12/1, 2011 at 10:41
5
Solved
I have a User < Country model. A user belongs to a country, but may not belong to any (null foreign key).
How do I set this up? When I try to insert a user with a null country, it tells me that...
Nealneala asked 14/4, 2011 at 19:46
3
Solved
I'm trying to replicate a SQL database in Cassandra, but, while I had no problem creating the tables, I found that I cannot find an example easy to understand that shows how I can create foreign ke...
Aldana asked 28/12, 2014 at 13:46
2
Solved
Can I make SQL sub queries in Check constraint ?
I've a post table with columns id, owner
I've another table action with columns user_id, post_id
Table user with columns id
post_id -> post.id ...
Spoilage asked 16/4, 2012 at 17:55
3
Solved
Why can you not have a foreign key in a polymorphic association, such as the one represented below as a Rails model?
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic =&...
Hyperbolic asked 28/5, 2009 at 17:32
5
Solved
This is a SQL design question. First, the setup. I have three tables:
A, which is automatically populated based on a query against a linked server. The data in this table cannot be changed;
B, wh...
Mullah asked 11/1, 2010 at 20:40
5
I have 60 tables. I want to drop 10 tables where these 10 tables are Constraints(PK,FK) to other 20 tables. While dropping these 10 tables, I need to truncate or delete data from the other 20 table...
Shreeves asked 20/2, 2013 at 5:21
5
I would like my django application to serve a list of any model's fields (this will help the GUI build itself).
Imagine the classes (ignore the fact that all field of Steps could be in Item, I hav...
Rosa asked 22/10, 2013 at 7:57
3
I have two tables
Table1(
FileID,
BundledFileID,
Domain)
and
Table2(
FileID,
FileType,
FileName)
In Table2 FileID and FileType are the composite primary key. I want to create a foreig...
Melinite asked 22/10, 2010 at 12:31
2
Solved
I'm having a little difficulty getting my head around relationships in Django models.
Could someone explain what the difference is between a OneToOne, ManyToMany and ForeignKey?
Epicardium asked 19/8, 2014 at 14:32
3
Solved
I have the situation:
Table1 has a list of companies.
Table2 has a list of addresses.
Table3 is a N relationship of Table1 and Table2, with fields 'begin' and 'end'.
Because companies may move o...
Keeping asked 17/2, 2014 at 19:23
6
Solved
I have a many-to-many relationship between User & Role, with a role_user table. My migrations are setup as so (simplified):
users table:
public function up()
{
Schema::create('users', functi...
Kingfish asked 22/7, 2014 at 20:34
7
Solved
If I am using the following SQL command in SQL Server 2008 to update a table with a foreign key constraint:
ALTER TABLE Employees
ADD FOREIGN KEY (UserID)
REFERENCES ActiveDirectories(id)
UserID...
Excurved asked 30/4, 2012 at 19:34
6
Solved
I have a model A with a ForeignKey to a model B.
In Django admin, how can I add a link in the admin page of model A next to the ForeignKey field which open the admin page of the model B ?
Roddie asked 3/3, 2015 at 13:21
4
Let's say I have two tables: Customer and City. There are many Customers that live in the same City. The cities have an uid that is primary key. The customers have a foreign key reference to their ...
Sthilaire asked 15/10, 2012 at 9:31
6
I ran into the Foreign Key Constraint Failed (code 787) error when I tried to upgrade my database. The only change I did was try to add a 4th entry to my InsertStatus. I looked around and I read th...
Peppi asked 30/3, 2015 at 8:17
3
Solved
I know the purpose of "Enforce foreign key constraint" in RDBMS. But is there any benefit when it's set to "NO" ?
Strobila asked 5/1, 2011 at 8:59
3
I know that is possible to declare primary key inline as
CREATE TABLE `my_table` (
`id` INTEGER PRIMARY KEY
);
my doubt is if is possible to declare foreign key in the same way, something like
...
Curhan asked 19/6, 2014 at 17:47
6
Solved
Just installed MySQL 5.5 on mac os x 10.6 and am having a strange issue on many tables. Below is an example. Inserting a row fails with a foreign key constraint when it shouldn't. The foreign key i...
Campbellite asked 6/4, 2011 at 13:17
2
Solved
I use Generic Foreign keys to relate different profiles with my Users model which is inherited from auth.User. I'm not able to do dumpdata though with the --natural option passed. It says,
Error:...
Down asked 24/12, 2012 at 12:54
1
I am making a web game in which each world can be part of one alliance.
class World(models.Model):
# rest of Model
alliance = models.ForeignKey('Alliance', related_name='allmember', default=None...
Tong asked 15/10, 2013 at 12:2
4
Solved
I'm pretty much new to opps and laravel both
So, to insert the values into my users and profiles table which hav OneToOne relationship, Here is how my store() method looks like
public function sto...
Whitehouse asked 11/6, 2015 at 18:23
6
Solved
I have set up a table that contains a column with a foreign key, set to ON DELETE CASCADE (delete child when parent is deleted)
What would the SQL command be to change this to ON DELETE RESTRICT?...
George asked 29/7, 2010 at 3:40
5
Solved
I'm following the instructions from the SQLite documentation at http://www.sqlite.org/foreignkeys.html however my attempt to add a foreign key is failing. Here are my create statements:
CREATE TAB...
Hallerson asked 18/7, 2012 at 15:42
1 Next >
© 2022 - 2024 — McMap. All rights reserved.