473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to ensure subtype uniqueness.

I cant find much info or a code on how to do this.
I have a generic table called Contact.
Then I have tables Person and Company that are subtypes of contact each with
attributes that are specific to the subtype.

The primary key for each table is a field called ContactID (PK to CONTACT,
FK and PK for PERSON and COMPANY).
How do I force an instance of contact to be either a person or a company but
not both?

Or in other words, if I create a new Contact how do I make sure the
ContactID exists also in the Person or the Company field but not both?

I know a solution is to combine all attributes in the contact table, but I
dont want to do that.
Everywhere I ve seen references on doing this with triggers or constraints
but not an actual sample of how it is done.
Closest to a solution I came is here,
http://www.mvps.org/access/tables/tbl0013.htm
but this is a solution based on the interface (forms) rather than the
database engine.
Is it possible in Access to have this done the way I want it?

Thanks for any help

Konstantinos
Nov 13 '05 #1
4 2626
Access, using the Jet engine, does not support triggers, nor stored
procedures.

If you choose to use Access to create a front-end or user interface to a
server database that supports them, you could use triggers. But, I see no
need for a trigger to retrieve the proper information; see below for
suggestions on a query.

You will have to handle ensuring that one or the other of the related
records is written, but not both, in your application... VBA event code.
That is why the solution at the FAQ site is as it is.

Because you do not specify what is in the "generic table", it is difficult
to offer specific suggestions. I can suggest that in the generic table, you
identify the type of contact, create your query linking to both, and use an
outer join in order to allow one of the related tables to return a Null
entry. By outer join, I mean rightclicking on the join line between the data
sources in the Query, and choosing "All records from Contacts and only those
that match from People" and "All records from Contacts and only those that
match from Companies".

Best of luck with your application.

Larry Linson
Microsoft Access MVP
"Konstantinos" <no*****@noemail.net> wrote in message
news:10*************@corp.supernews.com...
I cant find much info or a code on how to do this.
I have a generic table called Contact.
Then I have tables Person and Company that are subtypes of contact each with attributes that are specific to the subtype.

The primary key for each table is a field called ContactID (PK to CONTACT,
FK and PK for PERSON and COMPANY).
How do I force an instance of contact to be either a person or a company but not both?

Or in other words, if I create a new Contact how do I make sure the
ContactID exists also in the Person or the Company field but not both?

I know a solution is to combine all attributes in the contact table, but I
dont want to do that.
Everywhere I ve seen references on doing this with triggers or constraints
but not an actual sample of how it is done.
Closest to a solution I came is here,
http://www.mvps.org/access/tables/tbl0013.htm
but this is a solution based on the interface (forms) rather than the
database engine.
Is it possible in Access to have this done the way I want it?

Thanks for any help

Konstantinos

Nov 13 '05 #2
Thanks Larry,
I am using the concept of subtyping for a number of entities simply because
it looks conceptually stronger and at the implementation level it helps
avoid large numbers of nulls while at the same time avoids redundant
relationships (relationships are mapped to the supertype or subtype entities
as needed). I understand the performance might be affected as joins might
increase to handle subtypes but that issue does not concern me for now.
It looks that if I stick with Access I will have to master VBA to do descent
development.
One more question. Is SQL server as dependent on VBA as access is?

Regards, and thanks
Konstantinos

"Larry Linson" <bo*****@localhost.not> wrote in message
news:MyChd.4440$RA4.3690@trnddc06...
Access, using the Jet engine, does not support triggers, nor stored
procedures.

If you choose to use Access to create a front-end or user interface to a
server database that supports them, you could use triggers. But, I see no
need for a trigger to retrieve the proper information; see below for
suggestions on a query.

You will have to handle ensuring that one or the other of the related
records is written, but not both, in your application... VBA event code.
That is why the solution at the FAQ site is as it is.

Because you do not specify what is in the "generic table", it is difficult
to offer specific suggestions. I can suggest that in the generic table,
you
identify the type of contact, create your query linking to both, and use
an
outer join in order to allow one of the related tables to return a Null
entry. By outer join, I mean rightclicking on the join line between the
data
sources in the Query, and choosing "All records from Contacts and only
those
that match from People" and "All records from Contacts and only those that
match from Companies".

Best of luck with your application.

Larry Linson
Microsoft Access MVP
"Konstantinos" <no*****@noemail.net> wrote in message
news:10*************@corp.supernews.com...
I cant find much info or a code on how to do this.
I have a generic table called Contact.
Then I have tables Person and Company that are subtypes of contact each

with
attributes that are specific to the subtype.

The primary key for each table is a field called ContactID (PK to
CONTACT,
FK and PK for PERSON and COMPANY).
How do I force an instance of contact to be either a person or a company

but
not both?

Or in other words, if I create a new Contact how do I make sure the
ContactID exists also in the Person or the Company field but not both?

I know a solution is to combine all attributes in the contact table, but
I
dont want to do that.
Everywhere I ve seen references on doing this with triggers or
constraints
but not an actual sample of how it is done.
Closest to a solution I came is here,
http://www.mvps.org/access/tables/tbl0013.htm
but this is a solution based on the interface (forms) rather than the
database engine.
Is it possible in Access to have this done the way I want it?

Thanks for any help

Konstantinos


Nov 13 '05 #3
"Konstantinos" wrote
I am using the concept of subtyping
for a number of entities simply because
it looks conceptually stronger
I am not certain, from the example you gave, that it is as advantageous as
you hope.While a person and a company can both be considered "contacts", I
deal with people and entities rather differently. But, you can certainly
work with what you have described.

. . .
It looks that if I stick with Access I will
have to master VBA to do descent
development.
Server databases do not provide a user front end*. You are going to need
_some_ front end, and Access (IMNSHO) is the best and easiest in which to
develop front ends for the client-server environment. Assuming that you use
Access for your front end, you are going to need to learn VBA _anyway_. It
is not hard... it's descended from BASIC. Remember that was created with the
goal of being easy for development and was quite successful in attaining
that goal.

* some server database manufacturers do
sell (separately priced) software tools to
create front end / user interface -- for
example, Sybase sells PowerBuilder, and
Oracle has a product also. People that I
know who have used those and have also
used Access prefer Access as a front-end
development tool.
One more question. Is SQL server as
dependent on VBA as access is?
No, SQL Server does not "speak" VBA, but relies on T-SQL, a procedural
language based on SQL. But no matter how well-versed in T-SQL you are, you
can't use it to create the user interface, only to manipulate and extract
information within the SQL database.

The next version of SQL Server, however, will support use of VB.NET (and C#,
another .NET language) and this is considered by many to be a great
improvement.
Regards, and thanks
Konstantinos


You're welcome. I hope my comments have been helpful.
Nov 13 '05 #4
Many thanks for the long and informative table.
Btw, I use the term "entity" as the equivalent in a conceptual model for a
"table" in the physical and logical models.

Cheers,

Konstantinos

"Larry Linson" <bo*****@localhost.not> wrote in message
news:byDhd.9045$vB.4060@trnddc03...
"Konstantinos" wrote
I am using the concept of subtyping
for a number of entities simply because
it looks conceptually stronger


I am not certain, from the example you gave, that it is as advantageous as
you hope.While a person and a company can both be considered "contacts", I
deal with people and entities rather differently. But, you can certainly
work with what you have described.

. . .
It looks that if I stick with Access I will
have to master VBA to do descent
development.


Server databases do not provide a user front end*. You are going to need
_some_ front end, and Access (IMNSHO) is the best and easiest in which to
develop front ends for the client-server environment. Assuming that you
use
Access for your front end, you are going to need to learn VBA _anyway_. It
is not hard... it's descended from BASIC. Remember that was created with
the
goal of being easy for development and was quite successful in attaining
that goal.

* some server database manufacturers do
sell (separately priced) software tools to
create front end / user interface -- for
example, Sybase sells PowerBuilder, and
Oracle has a product also. People that I
know who have used those and have also
used Access prefer Access as a front-end
development tool.
One more question. Is SQL server as
dependent on VBA as access is?


No, SQL Server does not "speak" VBA, but relies on T-SQL, a procedural
language based on SQL. But no matter how well-versed in T-SQL you are, you
can't use it to create the user interface, only to manipulate and extract
information within the SQL database.

The next version of SQL Server, however, will support use of VB.NET (and
C#,
another .NET language) and this is considered by many to be a great
improvement.
Regards, and thanks
Konstantinos


You're welcome. I hope my comments have been helpful.

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Puvendran Selvaratnam | last post by:
Hi, First of all my apologies if you have seen this mail already but I am re-sending as there were some initial problems. This query is related to defining indexes to be unique or not and...
1
by: George C. Peters Iv | last post by:
ASPXCodeBehind vs. Code I work in a large development shop and as different people work on the same project, we've noticed that the SubType for the vb codebehind files will change to either...
2
by: Dirk Declercq | last post by:
Hi, Is it possible in Xml to enfore the uniqueness of an element based on his attribute value. Say I have this schema : <?xml version="1.0" encoding="UTF-8"?> <xs:schema...
1
by: Mr. Almenares | last post by:
Hello: I’m trying to do a schema with recurrent structure for a Book like a Node can have many Nodes inside or One leave. So, the leaves have an attribute that is Identifier. My goal is define...
2
by: Angel Of Death | last post by:
I have a method. It takes some XML as a parameter. Depending on the content of the XML it should create a specific object and call a KNOWN method. So: public void PersistXml(string XmlData){} ...
5
by: Alan Little | last post by:
I have affiliates submitting batches of anywhere from 10 to several hundred orders. Each order in the batch must include an order ID, originated by the affiliate, which must be unique across all...
34
gcoaster
by: gcoaster | last post by:
Hello Everyone! I have a question regarding "cascading combobox(s) list(s)" I would like: ComboBox 2 to show results from ComboBox 1's selection, then ComboBox 4 to show results from...
4
by: =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?= | last post by:
Hello. It's been about a year since I last did some C++ programming. I am now paying the price as I try to catch up with it. The following is the initial snippet of a simple program I am...
0
by: xsnox | last post by:
anyone?? am trying to create a database (mysql) from a super type subtype relation. my question is how do i create the tables with the right constrain (PK, FK) here is the proposed tables t ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.