foreign-keys

Linq to sql: Composite foreign key in one-many relation?

Hi, I'm trying to model a database in LINQ to SQL. I have a table JournalPosts. Each entity is associated with 1 or more senders or recipients. I have the following composite primary key in my table "JournalPosts": [Column(IsPrimaryKey = true)] public int CaseYear { get; set; } [Column(IsPrimaryKey = true)] public int ...

Foreign key definition in sqlite

Is there any way to define relationship among tables and give foreign keys among them while using sqlite in Objective c ...

Foreign key definition in sqlite

Cant add foreign key constraint in sqlite ........... ...

Is it of any drawback if a table has many (20+) foreign key constraints?

Let's says I have a table which has many fields linked to values from other "value tables". Naturally, I declare foreign key constraints on each and evary of them to enforce integrity. What if I finally get the number of such fields in the range of 20-30? Will it somehow "slow" table operations or not really? ADDED: Value tables are ex...

Understanding Update and Delete Rules for Relationships in SSMS 2008

Hello everyone, I am confused about what means the update and delete rule in SQL Server 2008 Management Studio when we define foreign key constraints. I also did not find related help documents (e.g. F1 help). Here is the screen snapshot. Appreciate if anyone could describe what do they mean and recommend some related documents to read...

How can I find which tables reference a given table in Oracle SQL Developer?

In Oracle SQL Developer, if I'm viewing the information on a table, I can view the constraints, which let me see the foreign keys (and thus which tables are referenced by this table), and I can view the dependencies to see what packages and such reference the table. But I'm not sure how to find which tables reference the table. For exam...

how to add foreign key constraint, SQL Server

hi guys, I have a registration table with primary key RegId. I have another table named Users, also contain RegId as Foreign key. When I delete one RegId from registration, I have to delete RegId from Users. Can anybody help? ...

Should I use a composite key for a map table, which is also used for a foreign key?

I am using ASP.NET and the Entity Framework to make a website. I currently have a map table for a many to many relationship between... let's say users and soccer teams. So: Users Teams UserTeams Part 1: Is it best practice to use a composite key for the primary key of the map table? In other words: UserTeams table PK UserId PK Te...

MYSQL errorno 121

Im getting this error in Mysql Create: Im Doing CREATE TABLE `blogReply` ( `Id` INT(24) NOT NULL AUTO_INCREMENT COMMENT 'Primary Key of This Table', `blogId` INT(24) NOT NULL COMMENT 'Blog where this reply was posted', `userId` INT(24) NULL COMMENT 'User the blog was posted by', `n...

To get primary and foreign keys right in ERD

I read my notes and I am now unsure about the keys. My logical diagram This table should be in line with the following physical ERD I have only one foreign key in the table Question. I would like to know should the question-id and question-tag in the table Question-tag-xref, AND question-id and answer in the table Answers be a...

Oracle optional relationship

What is the proper way to define an oracle table who has an optional foreign key relationship with another table? For instance, some employee records have defined the country they are from (a FK from countries table), and some have not. ...

Changing MySQL primary key when foreign key contraints exist

I have two already-existing tables which look (in part) roughly like this: CREATE TABLE parent ( old_pk CHAR(8) NOT NULL PRIMARY KEY ) ENGINE=InnoDB; CREATE TABLE child ( parent_key CHAR(8), FOREIGN KEY (parent_key) REFERENCES parent(old_pk) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB; I want to add a new ...

Getting Entity Framework to update both normal and relational fields

Hello, I have a problem figuring out the proper way to get foreign key fields to update using the Entity Framework. I do not have a problem updating them in the database, but rather on the interface. Here are the relevant tables to my question file:///C:/Users/Mike/Desktop/RelevantTables.bmp I have a "Team" form with a Master/Detail ...

How do I obtain information about a nullable foreign key from Information_Schema views?

I'm using the INFORMATION_SCHEMA views in Sql Server 2005 & 2008 to obtain metadata for a database: SELECT PK.TABLE_NAME as 'PK_TABLE_NAME', FK.TABLE_NAME as 'FK_TABLE_NAME', C.CONSTRAINT_NAME as 'CONSTRAINT_NAME' FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK ON C.CONS...

MySQL Error number 150 Create Fails on non existent foreign key

I was wrestling with mysql administrator trying to change the primary key on a table. It wouldnt let me so I delete foureign keys and rename the table, great no problem. I have now deleted the original table t_order_items but I cannot rename t_order_items2 to t_order_items, it fails with a 150 error. SO i figured I would craft up the ...

send data to a ForeignKey manually ?

Hi guys, i want to save data in two table mysql, that was nice, but now i change a field form Interget to FK.. the problem is that now i cant send the data to the field FK.... im new with Django, but im working in this way: @login_required def agregar_diligencia(request): if request.method =='POST': form = DiligenciaFor...

MySQL Foreign Key Constraint Confusion

Hey everyone, I have the following 'users' table in MySQL: CREATE TABLE `users` ( `uid` int(11) NOT NULL auto_increment, `fname` varchar(50) NOT NULL, `lname` varchar(50) NOT NULL, `role` varchar(75) NOT NULL, `region` tinyint(4) unsigned default NULL, `username` varchar(25) NOT NULL, `password` varchar(75) NOT NULL, `n...

How can I define a foreign key using netbeans 6.7?

I'm using JPA in netbeans with mysql and I need to define a foreign key. I want to do it graphically because it is very easy to create tables using netbeans 6.7 UI without dealing with SQL commands. Can you tell me how to do it?? ...

Linq to sql causing foreign key constraint errors

Here is the revelant code. TournamentTeam newTeam = new TournamentTeam(); TournamentTeams.InsertOnSubmit(newTeam); SubmitChanges(); TournamentParticipant newSignup = new TournamentParticipant { CheckedIn = false, TournamentID = tournamentId, UserID = participant...

How can I get the current user equivalent to an aspnet_User object?

My table, AccLink, has a foreign key, UserId, to the aspnet_User table created by the Membership Provider. When creating an object of type AccLink (I'm using the entity framework) I need to assign the aspnet_User by getting the current user object. I tried Membership.GetUser(userName) but it said it couldn't be converted to type aspnet...