foreign-keys

Error column not found in Laravel

我是研究僧i 提交于 2019-12-10 19:31:18
问题 This is my forumthread table: $table->increments('id'); $table->integer('user_id')->unsigned(); $table->foreign( 'user_id' )->references( 'id' )->on( 'users' ); $table->string('thread'); $table->string('slug'); $table->dateTime('published_at'); And this is my forumindex table: $table->increments('id'); $table->integer('user_id')->unsigned(); $table->foreign( 'user_id' )->references( 'id' )->on( 'users' ); $table->integer('forumthreads_id')->unsigned(); $table->foreign( 'forumthreads_id' )-

Find foreign key information using Perl/DBI/MySQL/InnoDB

早过忘川 提交于 2019-12-10 18:24:37
问题 I want to programmatically find the the foreign keys on a particular InnoDB table in my MySQL database. I'm using Perl, and I stumbled across $dbh->foreign_key_info . I've just tried using it but it seems a bit faulty. It doesn't return the ON DELETE, and ON UPDATE information, even though it implies it can. And it's also returning regular indexes. Thanks for any help. use strict; use warnings; use DBI; use Data::Dumper; my $dbh = DBI->connect("DBI:mysql:database=db;host=localhost", "user",

MySQL multiple Id lookups

落爺英雄遲暮 提交于 2019-12-10 17:54:19
问题 I'm trying to add a full text search to a system. The query I want to write needs to involve multiple lookups followed by the search (if that's even possible). I've got a table of teachers and a table of subjects. teacherProfile teacherId [int] - primary key subjectOneId [int] subjectTwoId [int] subjectThreeId [int] teacherBiography [text] subjects subjectId [int] subjectName [text] So ultimately I want a resultset along the lines of.. teacherId [int] teacherBiography [text] ( subjectOneName

mysql 5.6 foreign key constraint error; didn't occur in 5.5

帅比萌擦擦* 提交于 2019-12-10 17:34:29
问题 Tables involved: phppos_permissions_actions: mysql> show create table phppos_permissions_actions; +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Linq to SQL datacontext not updating for foreign key relationships

有些话、适合烂在心里 提交于 2019-12-10 17:11:59
问题 I'm writing a database test against a repository that uses L2S. In my database I have a Manifest entity and an AllocatedTransaction entity. The AllocatedTransaction entity has a foreign key to the Manifest's id. The DDL looks something like this: Manifest: Id - int - identity AllocateTransaction: Id - int - identity Quantity - int ManifestId - FK to Manifest In my test, I'm checking to see if AllocatedTransactions are coming back with the Manifest. The test looks like this: [TestMethod]

Constraint detail from information_schema (on update cascade, on delete restrict)

跟風遠走 提交于 2019-12-10 16:49:49
问题 Almost all the information I had needed about a database, I could find in information_schema This time I needed to read details of all foreign keys in a database through single query I found every thing in information_schema.key_Column_usage but could not find the constraints like on delete, on update I could do show create table for all individual tables. But is there any way to get these details through some select query like this? SELECT CONSTRAINT_NAME, TABLE_NAME,COLUMN_NAME, REFERENCED

Foreign key as Primary key

淺唱寂寞╮ 提交于 2019-12-10 16:21:20
问题 I designed tables like this: table1: students --------------------- PK id name number ... --------------------- table2: students_score --------------------- PK FK student_id math_score english_score ... --------------------- Question 1 If some students doesn't have scores at all, is it good table design? Question 2 If it's good design, then how can I make FK as PK in MySQL? I can't find out how. Everytime I try to make a relation like above SQLYog says this error: Can't create table 'students

Eclipse hibernate pojo generation include foreign keys

对着背影说爱祢 提交于 2019-12-10 15:43:21
问题 I have been following an excellent guide for generating pojos from a mysql database using hibernate. One can find the guide here for reference: Generate pojos with hibernate I am getting pojos which have fields that embed other objects when a foreign key was present. For example, user's have addresses. Hibernate is generating something like the following: public class User(){ private String name; private Integer uid; private Address address; } I have a problem, though, in that I want the

Same foreign key in multiple tables

无人久伴 提交于 2019-12-10 15:27:25
问题 I've seen posts on SO and through google stating that with Mysql you cannot have multiple foreign keys of the same name. My issue is how do I reference the same column from one table in multiple other tables. In my case I have a FAMILY table that contains FAM_ID. I want this to be a foreign key in my DOCUMENTS and CONTACT tables because rows in those have a relationship with FAM_ID. So if I understand what I've read correctly I need to name the column in DOCUMENTS and CONTACT different names

Sort queryset by a generic foreign key (django)?

只谈情不闲聊 提交于 2019-12-10 15:13:04
问题 I am using Django's comment framework which utilizes generic foreign keys. Question: How do I sort a given model's queryset by their comment count using the generic foreign key lookup? Reading the django docs on the subject it says one needs to calculate them not using the aggregation API: Django's database aggregation API doesn't work with a GenericRelation. [...] For now, if you need aggregates on generic relations, you'll need to calculate them without using the aggregation API. The only