foreign-keys

Foreign key referencing a view in Oracle

ⅰ亾dé卋堺 提交于 2019-12-23 06:50:37
问题 I'm attempting to reference a view with a foreign key but I am getting this error: "Error: ORA-02270: no matching unique or primary key for this column-list" However, I have created a primary key on this view and verified it in the Constraints tab in TOAD. This is the table I'm attempting to create: CREATE TABLE QUESTION ( QUESTION_ID INTEGER not null, CREATED_USER_ID INTEGER not null, CONSTRAINT PK_QUESTION PRIMARY KEY (QUESTION_ID), CONSTRAINT FK_USER FOREIGN KEY (CREATED_USER_ID)

How to set a database integrity check on foreign keys referenced fields

余生颓废 提交于 2019-12-23 06:40:06
问题 I have four Database Tables like these: Book ID_Book |ID_Company|Description BookExtension ID_BookExtension | ID_Book| ID_Discount Discount ID_Discount | Description | ID_Company Company ID_Company | Description Any BookExtension record via foreign keys points indirectly to two different ID_Company fields: BookExtension.ID_Book references a Book record that contains a Book.ID_Company BookExtension.ID_Discount references a Discount record that contains a Discount.ID_Company Is it possible to

How to set a database integrity check on foreign keys referenced fields

对着背影说爱祢 提交于 2019-12-23 06:36:10
问题 I have four Database Tables like these: Book ID_Book |ID_Company|Description BookExtension ID_BookExtension | ID_Book| ID_Discount Discount ID_Discount | Description | ID_Company Company ID_Company | Description Any BookExtension record via foreign keys points indirectly to two different ID_Company fields: BookExtension.ID_Book references a Book record that contains a Book.ID_Company BookExtension.ID_Discount references a Discount record that contains a Discount.ID_Company Is it possible to

Drop foreign-key constraint

霸气de小男生 提交于 2019-12-23 05:50:21
问题 How to drop a foreign key if I have not named it during creation create table abc( id number(10), foreign key (id) references tab(roll) ); even alter table abc drop foreign key mn_ibfk_1; is not working for me. I am using Oracle 10g. 回答1: As you did not specify a constraint name, Oracle generated one for you (something like SYS_034849548 ). You need to find the constraint name in order to be able to drop it: select constraint_name from user_constraints where table_name = 'ABC' and constraint

Creating a dynamic path when I upload images

前提是你 提交于 2019-12-23 05:50:13
问题 I'm trying to create a dynamic path for when my users upload images. It works something like this: View: photo = Photo(...) photo.save() photo.original.save(filename, content) Model: album = models.ForeignKey(Album) original = models.ImageField(upload_to="photos/%s/o" % str(album.id), max_length=200) But when I try to do this, Django says no way. Exception Value: 'ForeignKey' object has no attribute 'id' How can I access the model members of a ForeignKey object in this manner? Thanks. 回答1:

Enable referential integrity with nHIbernate using SQlite database

£可爱£侵袭症+ 提交于 2019-12-23 05:18:06
问题 Good evening everyone, I've got a project using nHibernate (2.1.2.4000) and System.Data.SQLite (1.0.66.0). I want to enforce NHibernate to create foreign keys when it creates the database or at least use the "foreign key" keyword then I'll be able to create the triggers. I googled but I didn't find any documentation on how to do that and I'm loosing the faith. I really don't want to (and I won't) check referential integrity inside my code. In a word: how do I enable referential integrity (or

DB Design Question about Nullable Foreign Keys and Normalization

最后都变了- 提交于 2019-12-23 05:12:27
问题 I'm hoping to get a consensus about what db schema is best for my situation to store 'type' information for Widgets in a table. A Widget can have only one type but that type can be either a Preset-Type OR a Custom-Type. I obviously create the preset types and a user would create a custom type. I'll be using MySQL and INNODB on a server. I'll also be using SQLite to store the same info on an App. But we'll just talk about the server here. I'm an app programmer, not a DB admin, but want to get

How to establish a many to one relationship between 2 tables for a field

断了今生、忘了曾经 提交于 2019-12-23 05:06:52
问题 I am building an database schema for a project and I am bit stuck on this issue. I have 2 tables: USER table: Id Name Contact_ID 1 Arun 2 2 Barath 3 3 Charan 2 4 Dinesh 1 CONTACT table: ID Name Phone Mail 1 Mahesh 1234 Mahesh@Yahoo.com 2 Suresh 54321 Sureh@Google.com 3 Jayesh 9876 Jayesh@Bing.com 4 Ganesh 98754 Gahesh@Safari.com Each of the users in USER will have a contact in CONTACT. If a user has a single contact then I can use a foreign key relationship on Contact_ID in USER and build the

Foreign Key Constraints may cause cycles or multiple cascade paths [duplicate]

大憨熊 提交于 2019-12-23 04:42:09
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Foreign key constraint may cause cycles or multiple cascade paths? I am getting the following error while creating the table listed below. Msg 1785, Level 16, State 0, Line 1 Introducing FOREIGN KEY constraint 'FKFacSupervisor' on table 'Faculty' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Msg 1750, Level 16, State 0,

In JPA, having a many-to-one as primary key throws referential integrity constraint violation

你说的曾经没有我的故事 提交于 2019-12-23 03:18:10
问题 I have defined the following entities: @Entity public class Child implements Serializable { @Id @ManyToOne(cascade = CascadeType.ALL) public Parent parent; @Id public int id; } @Entity public class Parent { @Id public int id; } When I try to persist a Child with the following code: Parent p = new Parent(); p.id = 1; Child c1 = new Child(); c1.id = 1; c1.parent = p; em.persist(c1); Hibernate throws a 'Referential integrity constraint violation' error: Caused by: org.h2.jdbc.JdbcSQLException: