foreign-key-relationship

ServiceStack OrmLite How can I achieve automatic setting of foreign key/related properties?

拜拜、爱过 提交于 2019-12-10 09:30:25
问题 I have created the following example to test Foreign Keys and up to this point, it works well. What I would like to be able to do, is use this framework that I built to set the property of the relationship and have it Save the child object when the Parent is saved and automatically set the PrimaryKey and Foreign Key. The DataManager class exposes the Connection public class DataManager { DataManager() { OrmLiteConfig.DialectProvider = SqliteDialect.Provider; ConnectionString = SqliteFileDb;

Self referencing foreign-key constraints and delete

南楼画角 提交于 2019-12-10 03:58:21
问题 what is the recommended way to handle self-referencing foreignkey constraints in SQL-Server? Table-Model: fiData references a previous record in tabData. If i delete a record that is referenced by fiData , the database throws an exception: "The DELETE statement conflicted with the SAME TABLE REFERENCE constraint "FK_tabDataPrev_tabDataNext". The conflict occurred in database "MyDataBase", table "dbo.tabData", column 'fiData'" if Enforce Foreignkey Constraint is set to "Yes". I don't need to

laravel - why function call with no parentheses?

十年热恋 提交于 2019-12-10 02:06:36
问题 I see this in a laravel tutorial : Auth::user()->item; where item is a function, inside models\User.php : function item() { return $this->hasMany('Item', 'owner_id'); } where Item is for models\Item.php So why the parentheses is not needed when item function is called ? Like : Auth::user()->item(); If I put the parentheses, the browsers goes crazy and crash. Also, if I rename Item.php to Item2.php, rename class Item to Item2, and I do hasMany('Item2', 'owner_id') , it won't work. But why ?

GORM prevent creation of a foreign key constraint for a Domain

早过忘川 提交于 2019-12-09 03:21:40
问题 I am developing a web based application in Grails. I have come across a situation where I would like to try and suppress GORM from creating a foreign key constraint on a field in a table. I have a domain class which is part of a class hierarchy. The domain class essentially acts as a link to a target domain. The target domain can be of different types and each of the subclasses of this link domain is designed to provide the link for each specific type of linked item. These linked items have

How to add an EF6 Association to a Candidate Key / Unique Key which is not the Primary Key?

被刻印的时光 ゝ 提交于 2019-12-09 02:36:15
问题 Using Schema First , I have a database structure, as so ExternalDataItems --- edataitem_id PK -- surrogate auto-increment - NOT for FK relation here datahash UX -- Candidate Key / Unique Index (binary(20)) ExternalMaps --- emap_id PK ext_datahash FK on ExternalDataItems.datahash - NOT referencing the surrogate PK and after generating the SSDL/CSDL 1 has this <Association Name="FK_ExtMaps_ExtDataItems"> <End Multiplicity="1" Role="ExternalDataItems" Type="Store.ExternalDataItems" /> <End

SQLite UPDATE field in one table based on foreign key of another table

与世无争的帅哥 提交于 2019-12-08 12:32:53
问题 As in this question (SQLite field with a list of foreign keys), I'm trying to keep my real estate agents and listings in an SQLite DB with python. I did as suggested and now have tables that look like this: CREATE TABLE listings( listing_id INTEGER PRIMARY KEY AUTOINCREMENT, listing_address TEXT UNIQUE NOT NULL, acq_date DATE agent_id INTEGER, FOREIGN KEY (agent_id) REFERENCES agent (agent_id) ) CREATE TABLE agent( agent_id INTEGER PRIMARY KEY AUTOINCREMENT, agent_name TEXT NOT NULL, agent

Restkit - Core Data One-To-One Relationship Mapping via Foreign Key

旧城冷巷雨未停 提交于 2019-12-08 12:15:49
问题 I have spent the last few hours trying a number of different solutions to this problem by looking at similar similar problems that have been resolved on StackOverFlow threads. However, I have hit a brick wall. Some background. Using Restkit 0.22 and Core Data to Persist 2 Objects and set up a relationship between them. The two Objects that I am modelling are as follows, Relationships are also included in the form of a One-One relationship between COAgendaItem and COMapItemLocation (The

SQLite field with a list of foreign keys

心不动则不痛 提交于 2019-12-08 09:32:54
问题 I am building an SQLite DB to keep my real estate agents' listings. I have been able to use a foreign key to identify a listing for each agent, but I want to make a list of listings in each agent's record; moving from a one-to-one relationship between agents and listings to a one-to-many relationship. Looking here: http://www.sqlite.org/draft/foreignkeys.html , there is no mention of a field that is a 'list of foreign keys'. Is what I'm trying doable? I considered that, as a workaround, I

Connecting One table to Many tables

送分小仙女□ 提交于 2019-12-08 02:32:21
问题 I am building a commenting system where people can comment on uploaded files, messages and to-do items. What is the best way to connect the comment table table to the other various tables? Possible Solutions Solution one - use a two field foreign key. CREATE TABLE `comments`( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, foreign_key INT NOT NULL, table_name enum('files','messages','to-do'), user_id INT NOT NULL, comment TEXT NOT NULL); Solution two - Each table would have a primary key unique

One-to-One relationship in MS Access

ぐ巨炮叔叔 提交于 2019-12-08 00:38:54
问题 I'm having trouble in creating a one-to-one relationship between two tables in MS Access - when I create the relationship, it defaults to "Many-to-one", and I don't see an option to change it. Is there a way to do this? 回答1: Access has no such concept. You can either conflate the two tables into one, or place unique indexes on both tables for the common field(s). Are there other benefits you would expect? You could I suppose create FK relationships in both directions, but I'm not sure what it