How can I create a composite key on multiple columns, one of which can have some value but not null (or some constant value)?
For example:
PK Loc_ID Date Time Cancelled
1 1 01/01/2010 10:00AM YES
2 1 01/01/2010 10:00AM YES
3 1 01/...
I want to make a composite key (well that's the idea but I'm open to other suggestions) on a Documents table. It would consist of two columns, year (2010,...) and an ID, which would be autoincrementing but it should restart itself every year.
So keys like these 2010-1, 2010-2, ..., 2011-1, 2011-2, ... and, preferrably those keys should ...
Hi, i have the following tables in my database:
Announcements:
- AnnouncementID (PK)
- Title
AnouncementsRead (composite PK on AnnouncementID and UserID):
- AnnouncementID (PK)
- UserID (PK)
- DateRead
Users:
- UserID (PK)
- UserName
Note: Usually i'd map the AnnouncementsRead using a Many to Many relationship but this table also ha...
I am sure I am not the first who has composite unique keys in tables and who wants to validate them. I do not want to invent the bicycle so I ask here first. I have several tables that have 'id' columns as primary keys and two other columns as unique composite keys. It would be nice to have a validation rule to check that the submitted e...
Inside my JSF I did
<h:outputLabel value="Group:" for="group" />
<h:inputText id="group" value="#{newUserController.group.groupKey.groupId}" title="Group Id" />
Group.java
@Entity
public class Group {
@EmbeddedId
private GroupKey groupKey;
@ManyToOne
@JoinColumn(name="userId")
private User user;
//setter, g...
How does Sql Server handle fill factor on tables with clustered indexes on composite primary keys?
I would assume a key node value would be generated based on the fields that make up the clustered index. Would this mean that each new row inserted would effectively get inserted to at the end of the index?
...
A primary key is an attribute or set of attributes that uniquely identifies a row in a table. But a primary key has not only to be unique, but also minimal. Why is that necessary?
...
I was working on an Access database which loved auto-numbered identifiers. Every table used them except one, which used a key made up of the first name, last name and birthdate of a person. Anyways, people started running into a lot of problems with duplicates, as tables representing relationships could hold the same relationship twice o...
Hello All,
I have two table Part and SubPart. Part table has general fields like id, name, desc etc. The SubPart table has part_id, sub_part_id as composite key. Both of these columns are referring to Part table and has a one to many mapping for each of them, like for each part_id in the Part table there can be multiple entries in SubPar...
Hi,
I'm trying to load nhibernate mapping for POCO classes at runtime with following lines:
var persistentClass = NHibernateHelper.Configuration.GetClassMapping( type );
var property = persistentClass.GetProperty( propertyName );
It works fine except it fails on property GroupId on a class with following mapping:
<class name="GroupP...
In this code how to generate a Java class for composite key (how to composite key in hibernate):
create table Time (
levelStation int(15) not null,
src varchar(100) not null,
dst varchar(100) not null,
distance int(15) not null,
price int(15) not null,
confPathID int(15) not null,
...
I'm encountering somewhat of an, uh, unorthodox design and I'm not quite sure how to handle it. The table I'm trying to map looks like:
TABLE example {
ID INT,
CATEGORY VARCHAR,
PROPERTY VARCHAR,
VALUE VARCHAR);
A single id can have several rows (obviously, not a primary key). As an example, it could look like:
# ID ...
I'm upsizing a Jet database to SQL Server Express 2008 R2 and before doing so, I'm re-evaluating the schema (it was designed in 1997-98, and the guy who designed it (i.e., me) was something of a moron!).
My question is about N:N join tables with a two-column composite key. In Jet, joins on the first column of a two-column composite key...
In my database application, when I try to attach a page to a site, I get the following error:
System.InvalidOperationException: Can't perform Create, Update or Delete operations on 'Table(Junc_Page_Site)' because it has no primary key.
I intend a page to be able to be added to multiple sites - by using a junction table.
Below is the ...
Hello,
I have a 2 enum values representing a mapping to object which I'm (currently) modeling with a HashMap with the 2 enums values are used as key and the object is the value.
This is inefficient because what I'm doing is creating a new CompositeKey(Enum1 enum1, Enum2 enum2) for each combination of the Enum1.values() x Enum2.values()...
We have a fairly big DB (~200 tables) which almost entirely uses composite primary keys and composite foreign keys, using a single "base table" from which every other table inherits part of its primary key:
Parent has single column primary key ParentId
Child has composite primary key (ParentId, ChildId) and foreign key ParentId
Nephew ...
Hi guys,
I hope anyone can help. I have to develop up against this third party database and I am kind of stuck with their crappy design. Still, I want to use NHibernate so I will have to jump through hoops.
Simplified, there is this "Event" table that has a relation a "Transportation" table. The transportation table has a composite p...