foreign-keys

Rails model with foreign key to itself

僤鯓⒐⒋嵵緔 提交于 2019-12-11 07:44:10
问题 I have an Oracle DB schema which includes a "users" table. This table has two non-null foreign keys to an editor and creator which are also users. The schema dump looks like this: create_table "users", :force => true do |t| t.integer "creator_id", :precision => 38, :scale => 0, :null => false t.integer "editor_id", :precision => 38, :scale => 0, :null => false end add_foreign_key "users", "users", :column => "creator_id", :name => "r_user_creatorid", :dependent => :nullify add_foreign_key

TYPO3 Extension Builder Foreign Key

試著忘記壹切 提交于 2019-12-11 07:12:39
问题 Why does the TYPO3 Extension Builder don't generate Foreign keys? I've set some relations between the models, but in SQL Code there are noe FKs only colums for the Value of the key. Does anyone can help me? 回答1: Cite from Kartsen Dambekalns It is a half-conscious design decision. Just look up the date when foreign key constraints where introduced in MySQL, and compare to when TYPO3 was 'born'. Of course it would be great to add such references, especially since MySQL can always handle themm,

Insert mysql on foreign key id php

和自甴很熟 提交于 2019-12-11 07:08:33
问题 I have 2 tables, clubs and fixtures clubs id (int) name (text) fixtures id (int) hometeam (int, foreign key to clubs id) awayteam (int, foreign key to clubs id) datetime (datetime) Each fixtures record uses an ID for the hometeam and awayteam as per the foreign key relationship. I need to do an insert into the fixtures table, but I only have the hometeam name not the hometeam id. Is there a way of doing this through the foreign key relationship, without having to separately lookup the

ASP.NET Membership Provider: Defining a foreign key to aspnet_Users.UserName

无人久伴 提交于 2019-12-11 06:49:33
问题 I'd like to setup a foreign key to a default membership table but I'm getting an error when trying to define it. I'm using the default aspnet_Users table and also my own Posts table. I'm trying to setup the tables as follows: aspnet_Users UserId (PK) uniqueidentifier UserName nvarchar(256) Posts PostID (PK) int UserName (FK -> aspnet_Users.UserName) nvarchar(256) However, when I try to set this up using the VS 2010 designer, it gives me the following error: The columns in table 'aspnet_Users'

Changing a record in a table (sql server) that has foreign keys?

假如想象 提交于 2019-12-11 06:38:10
问题 Does anyone know if there is a quicker way of editing a record that has foreign keys in a table (in sql server).. i will explain.. i have approx 5 tables that have there own ID but are linked together using a foreign key... Hence i needed to change the foreign key (the contract number in my case), but i had to copy each record to a new record and edit it that way... As if i try to edit the contract number it gives me the standard error of being associated and violates a foreign key etc Surly

Entity Framework 6.X and one-to-one relationship

為{幸葍}努か 提交于 2019-12-11 06:29:33
问题 I have the following model: public partial class Driver { public string FirstName { get; set; } public string LastName { get; set; } public string Nickname { get; set; } public virtual AspNetUser AspNetUser { get; set; } ...... } public partial class AspNetUser { public string Id { get; set; } public string UserName { get; set; } public virtual Driver Driver { get; set; } ...... } and the following mapping: this.HasOptional(c => c.Driver) .WithOptionalPrincipal(a => a.AspNetUser) .Map(m => m

MySQL Error 1215: Cannot add foreign key constraint, innodb, new tables

僤鯓⒐⒋嵵緔 提交于 2019-12-11 06:17:19
问题 I like to add foreign keys, this table, but not work! If I try new tables not work, but other, old tables it works. What's the problem? CREATE TABLE `tanora` ( `idtanora` int(11) NOT NULL, `tema` varchar(250) NULL, `megjegyzes` varchar(255) DEFAULT NULL, `datum` date NOT NULL, `osztaly` varchar(20) NOT NULL, `megtartott` int(11) NOT NULL, `targy` varchar(45) NOT NULL, `kezdete` time NOT NULL, `vege` time NOT NULL, PRIMARY KEY (`idtanora`), UNIQUE KEY `idtanora_UNIQUE` (`idtanora`), KEY

Form control in Django ForeignKey

给你一囗甜甜゛ 提交于 2019-12-11 06:14:10
问题 My Models: class Faculty(models.Model): name = models.CharField(max_length=30) class Program(models.Model): name = models.CharField(max_length=30) faculty = models.ForeignKey(Faculty) class Student(models.Model): name = models.CharField(max_length=30) faculty = models.ForeignKey(Faculty) program = models.ForeignKey(Program) Let I have Two Faculty: Science Management And I have 3 Programs in each: Science B. Computer B. Software B. Civil Management BBA BBS BBI And What I want is When A studen

Django: cascade on_delete option not working

只谈情不闲聊 提交于 2019-12-11 06:07:07
问题 I am using django 1.2.4 (Confirmed through the shell with import django django.VERSION ) and am attempting to use the on_delete=models.SET_NULL setting on a ForeignKeyField but I get the error: AttributeError: 'module' object has no attribute 'SET_NULL' This is how I was attempting to use the setting: relatedRec = models.ForeignKey(Record, null=True, blank=True, on_delete=models.SET_NULL) The model was already created and I am now trying to alter it. I didnt think that would be a problem but

SQL Error 'Parent Key Not Found' for Improperly Used Foreign Keys?

谁说胖子不能爱 提交于 2019-12-11 05:59:02
问题 I updated my attempt, keeping some things as CHAR's and still get a similar error:ERROR at line 1: ORA-02091: transaction rolled back ORA-02291: integrity constraint (MMM1339.ITEMNO_PHAR_FK) violated - parent key not found Requisition's foreign keys all have values in the different supply primary keys, so I'm not sure why there is still an issue. CREATE TABLE SUPPLIER (SUPPLIERNO CHAR(6), SUPPLIERNAME VARCHAR2(100), PHONENO VARCHAR2(12), ADDRESS VARCHAR(100), FAXNO VARCHAR(12), CONSTRAINT