Let's say I have books which can be romance, fiction, or mystery. I have 2 realistic options to store this data. One is to have a type column in my books table that is a string with the value "romance", "fiction", or "mystery". The other is to create a book_types table and store the types in there. Then my books would have a type_id ...
As the result of a form post, I'm trying to save a new Brand record. In my view, Gender is a dropdown, returning an Integer, which is populated from ViewData("gender")
I've setup my link as follows:
gID = CInt(Request.Form("Gender"))
Brand.GenderReference.EntityKey = New EntityKey("DB_ENTITIES.Gender", "Id", gID)
TryUpdateModel(Brand)
...
Hi,
Just using this as an example...
Here are the columns in my UserProfile table:
ProfileID (Primary key)
UserID (Foreign key)
Address
PhoneNumber
now, when I want to add a new user to the database using LINQ to Entities, here is what I'm doing:
UserProfile profileToAdd;
profileToAdd.ProfileID = 0;
profileToAdd.Address =...
Hi folks,
I've got two tables and I've added a foreign key constraint. Kewl - works great. Now, is it possible to further constrain that relationship against some data in the parent table?
Basically, I have animals in the parent table, and for the child table wishto only contain data where the parent data are .... um .. mammals.
eg.
...
So, a simple question. First, I did read this StackOverflow question, so no need to point me towards it.
I'm working on a similar problem right now. Specifically, I have a database with an Auditing table that is used to store auditing info about other tables within the db. The basic form of this table is:
ID, EntityID, EntityTypeID, Ac...
Hi,
I have two tables:
CREATE TABLE dbo.country
(
cntry_id VARCHAR(2) NOT NULL,
name VARCHAR(50) NOT NULL,
CONSTRAINT pk_country PRIMARY KEY (cntry_id)
CREATE TABLE dbo.city
(
city_id VARCHAR(3) NOT NULL,
name VARCHAR(50) NOT NULL,
cntry_id VARCHAR(2) NOT NULL,
CONSTRAINT pk_city PRIMARY KEY (city_id),
FO...
If I were to have 2 tables, call them TableA and TableB. TableB contains a foreign key which refers to TableA. I now need to add data to both TableA and TableB for a given scenario. To do this I first have to insert data in TableA then find and retrieve TableA's last inserted primary key and use it as the foreign key value in TableB. I t...
I'm bringing down a strongly typed dataset table into a datagridview. then adding a column of combo boxes to let the foreign keys be selected by name instead of ID. Perhaps there's an easier way to do this.
can I transform the typeID column into a comboboxcolumn while still being able to cast the datasource back to my strongly typed da...
I am trying to model a tree relationship in a table. For instance, there are "Categories" and categories can themselves be inside a Parent category.
My schema is:
id int PRIMARY KEY,
parent_id int,
name
My question is, should I label the parent_id column as a Foreign key? Foreign implies "outside" and not self-referencing. Is ther...
Hi folks,
I've got some tables in my Linq2Sql designer (in Visual Studio 2008). Works great.
Now, I just tried dropping in a View onto the designer. It dropped on there ok, but there's NO foreign keys/associations.
hmm. Ok, so then I tried to manually add an association between the View and a parent table. That worked .. but when i ...
What algorithms are known to perform the task of updating a database by inserting, updating, and deleting rows in the presence of database constraints?
More specifically, say that before images of rows to be deleted, after images of rows to be inserted, and both images of rows to be updated are in memory. The rows might be for several t...
I've tried searching on this error and nothing I've found helps me, so I apologize in advance if this is a duplicate and I'm just too dumb to find it.
I've created a model with MySQL Workbench and am now attempting to install it to a mysql server.
Using File > Export > Forward Engineer SQL CREATE Script... it outputs a nice big file fo...
Problem as follows:
I'm in charge of a creating a web services interface to a system with a huge database (hundreds of tables). The top level table in the database is "Accounts", with primary key Account_Id. Each row in any table can ultimately be traced back to a single account.
Each account should have access to their own account v...
In my current project I have data about colors.
Each color is either a real color (with RGB values) or is a "container color" that exist out of multiple layers of colors.
This potentially creates circular references which will have to be caught at application level (but that's another question)
So I have
Colors
------
+ (PK) Id
Color...
Hi,
I'm designing a mySQL DB and I'm having the following issue:
Say I have a wall_posts table. Walls can belong to either an event or a user.
Hence the wall_posts table must references either event_id or user_id (foreign key constraint).
What is the best way to build such a relationship, considering I must always be able to know who ...
I'm running into the problem described by KB321843 and this question. Both only talk about MS SQL Server 2005 (or older), while I'm running 2008.
I'd really had hope that this is fixed in recent versions, but it doesn't seem like it is. Could someone confirm this (or, better tell me how I could get it to work)?
...
I'm not sure why these have to be unique, but from reading the MySQL forums it appears that they do. However, I think it has something more to do with the INDEX name. I have two tables that have foreign key constraints referencing the same primary key on a third table. If it helps, I'm using MySQL workbench to design the schema.
I usua...
Basically, I have a model where I've created a superclass that many other classes share, and then each of those classes has some unique features that differ from each other. Let's say class A is the superclass, and class B, C, and D are children of that class.
Both class B and class C can have multiples of class D, however I've seen tha...
class Achievement(MyBaseModel):
parent_achievement = models.ForeignKey('self', blank=True, null=True, help_text="An achievement that must be done before this one is achieved") # long name since parent is reserved
I can do :
Achievement.objects.get(pk="1").parent_achievement
which is great. But how do I get all the children?
Ach...
Will I suffer consequences later if I add FKs with ON DELETE CASCADE and such?
If not, what naming convention should I be using for FKs within MySQL for CakePHP?
...