querry on ID's and IDREF in DTD

M

Maulik Thaker

Hi ppl,

I have a querry based on ID. Suppose if i have got two primary keys
(ID) and one foreign key (IDREF) in the same attribute, is there a way
to use them.



For example :

INSTRUCTUR

1) FirstName varchar(32) Primary key
2) LastName varchar(32) Primary key
3) emailID varchar(64) Foreign Key

Now the question is what could be the possible DTD for this kind of
situation.
Can anyone please let me know regarding this and if u have any good
suggestions for the weblink for such kind of DTD's please let me know.

Thanks in advance.

Maulik.
 
J

Joe Kesselman

DTDs do not support the concept of multiple keys. Only one attribute per
element type may be declared as having type ID.

(http://www.w3.org/TR/2004/REC-xml11-20040204/#one-id-per-el)

If you're working with schemas rather than DTDs, you could try using
keys rather than IDs. Or you could just have your software explicitly
search for elements that have the appropriate attribute/value pair,
using XPaths or something of that sort.
 
J

Joe Kesselman

DTDs do not support the concept of multiple keys. Only one attribute per
but what if i wanted to implement that structure using DTD only..

Then the DTD can't help you. As I said:
 
A

Aalap

hey

Thanks again.....

suppose i took instructor as an element and first name , last name ,
email as the child elements.......and each element should have an
attribute called first name ,last name and email respectively . and in
that case first name and last name can have and ID rt?

Aalap
 
J

Joseph Kesselman

suppose i took instructor as an element and first name , last name ,
email as the child elements.......and each element should have an
attribute called first name ,last name and email respectively . and in
that case first name and last name can have and ID rt?

Yes. Ugly, but yes.
 
J

Joe Kesselman

Note that IDs must be unique, though. So if you make firstname an ID,
nobody else can have the same firstname; if lastname is also an ID, not
only can no two people have the same lastname, but no lastname can be
the same as any firstname.

I doubt that's what you're trying to achieve. IDs are generally the
wrong solution for anything except pointing to a specific location in a
document.
 
A

Aalap

Hey

even i just realised that . i surely dont want that
So there is no way i can use ID for a composite key for a table....
also i am getting and error in XML spy
This file is not valid:
Required attribute 'dept' is missing.
even though i have it in the dtd .

Thanks
Aalap
 
J

Joe Kesselman

Required attribute 'dept' is missing.
even though i have it in the dtd .

Sounds like the problem is that you do have it in the DTD but it's
missing in the instance document.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,434
Messages
2,571,685
Members
48,796
Latest member
Greg L.

Latest Threads

Top