473,396 Members | 2,030 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,396 software developers and data experts.

How do I add an autonumber

I have a 'supertype' table with only one field: autonumber. Call this table
the 'parent' table. There are two subtypes, 'androids' and 'martians'.
Martian have only one thing in common: they give birth to identical mules.
So each android and a martian have primary key which is a foreign key to the
parent table. Now, I want to insert a new record in 'android' or 'martian'.
This can be done easily using MS-Access forms. But I want to do so using
SQL. To add a martian, I first need the parent ID. How do I know what it
is?

Here are my tables

tlbParent
Autonumber (PK)

tblAndroid
ParentFK (PK)
AndroidFields

tblMartian
ParentFK (PK)
MartianFields

tblMules
ParentFK
MuleFields

If I want to insert an Android, I need to first insert a record in parent.
How do I do that, if I don't know the autonumber value of the record?

Many thanks for your help
Ilan
Nov 12 '05 #1
3 4750
Apologies for the early post before proof reading. Here is my post again,
proof read:

I have a 'supertype' table with only one field: autonumber. Call this table
the 'parent' table. There are two subtypes, 'androids' and 'martians'.
Androids and Martians have only one thing in common: they can unilaterally
birth to mules.
Each android and Martian have a primary key, which is a foreign key to the
parent table (and the parent table has only one field: autonumber). Now, I
want to insert a new record in 'android' or 'Martian.
This can be done easily using MS-Access forms. But I want to do so using
SQL. To add a Martian, I first need the parent ID. How do I know what it
is?

Here are my tables

tlbParent
Autonumber (PK)

tblAndroid
ParentFK (PK)
AndroidFields

tblMartian
ParentFK (PK)
MartianFields

tblMules
ParentFK
MuleFields

If I want to insert an Android, I need to first insert a record in parent.
How do I do that, if I don't know the autonumber value of the record?

Many thanks for your help
Ilan


"Ilan Sebba" <ilan underscore sebba at btinternet stop com de***@yahoo.com>
wrote in message news:ne********************@lnews.actcom.co.il...
I have a 'supertype' table with only one field: autonumber. Call this table the 'parent' table. There are two subtypes, 'androids' and 'martians'.
Martian have only one thing in common: they give birth to identical mules.
So each android and a martian have primary key which is a foreign key to the parent table. Now, I want to insert a new record in 'android' or 'martian'. This can be done easily using MS-Access forms. But I want to do so using
SQL. To add a martian, I first need the parent ID. How do I know what it
is?

Here are my tables

tlbParent
Autonumber (PK)

tblAndroid
ParentFK (PK)
AndroidFields

tblMartian
ParentFK (PK)
MartianFields

tblMules
ParentFK
MuleFields

If I want to insert an Android, I need to first insert a record in parent.
How do I do that, if I don't know the autonumber value of the record?

Many thanks for your help
Ilan

Nov 12 '05 #2

"Ilan Sebba" <ilan underscore sebba at btinternet stop com de***@yahoo.com>
wrote in message news:ne********************@lnews.actcom.co.il...
Apologies for the early post before proof reading. Here is my post again,
proof read:

I have a 'supertype' table with only one field: autonumber. Call this table
the 'parent' table. There are two subtypes, 'androids' and 'martians'.
Androids and Martians have only one thing in common: they can unilaterally
birth to mules.
Each android and Martian have a primary key, which is a foreign key to the
parent table (and the parent table has only one field: autonumber). Now, I
want to insert a new record in 'android' or 'Martian.
This can be done easily using MS-Access forms. But I want to do so using
SQL. To add a Martian, I first need the parent ID. How do I know what it
is?

Here are my tables

tlbParent
Autonumber (PK)

tblAndroid
ParentFK (PK)
AndroidFields

tblMartian
ParentFK (PK)
MartianFields

tblMules
ParentFK
MuleFields

If I want to insert an Android, I need to first insert a record in parent.
How do I do that, if I don't know the autonumber value of the record?

Many thanks for your help
Ilan


"Ilan Sebba" <ilan underscore sebba at btinternet stop com de***@yahoo.com>
wrote in message news:ne********************@lnews.actcom.co.il...
I have a 'supertype' table with only one field: autonumber. Call this

table
the 'parent' table. There are two subtypes, 'androids' and 'martians'.
Martian have only one thing in common: they give birth to identical mules.
So each android and a martian have primary key which is a foreign key to

the
parent table. Now, I want to insert a new record in 'android' or

'martian'.
This can be done easily using MS-Access forms. But I want to do so using
SQL. To add a martian, I first need the parent ID. How do I know what it
is?

Here are my tables

tlbParent
Autonumber (PK)

tblAndroid
ParentFK (PK)
AndroidFields

tblMartian
ParentFK (PK)
MartianFields

tblMules
ParentFK
MuleFields

If I want to insert an Android, I need to first insert a record in parent.
How do I do that, if I don't know the autonumber value of the record?

Sorry, but I fail to see why you need the parent table at all. Why not just
have AutomNumber PKs on each of the other tables? Are the fields in the other
tables different from each other?
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 12 '05 #3
"Sorry, but I fail to see why you need the parent table at all. Why not
just
have AutomNumber PKs on each of the other tables? Are the fields in the other tables different from each other?"
Each androids can give birth to many mules. Each martians can also give
birth to many mules. So the mules has a many-to-one relationship with both
androids and martians. So I have a choice: I can either have two foreign
keys in the mule table, one to androids and one to martians. I was advised
that this is not good practice, and it is better to have the 'androids' and
martians as subtypes to a parent supertype which contains their 'common'
fields. Unfrotunately, the only thing they have in common is that they give
birth to mules.

Is this starting to make sense?

Many thanks for bearing with me.

Ilan
"Rick Brandt" <ri*********@hotmail.com> wrote in message
news:bp*************@ID-98015.news.uni-berlin.de...
"Ilan Sebba" <ilan underscore sebba at btinternet stop com de***@yahoo.com> wrote in message news:ne********************@lnews.actcom.co.il...
Apologies for the early post before proof reading. Here is my post again, proof read:

I have a 'supertype' table with only one field: autonumber. Call this table the 'parent' table. There are two subtypes, 'androids' and 'martians'.
Androids and Martians have only one thing in common: they can unilaterally birth to mules.
Each android and Martian have a primary key, which is a foreign key to the parent table (and the parent table has only one field: autonumber). Now, I want to insert a new record in 'android' or 'Martian.
This can be done easily using MS-Access forms. But I want to do so using SQL. To add a Martian, I first need the parent ID. How do I know what it is?

Here are my tables

tlbParent
Autonumber (PK)

tblAndroid
ParentFK (PK)
AndroidFields

tblMartian
ParentFK (PK)
MartianFields

tblMules
ParentFK
MuleFields

If I want to insert an Android, I need to first insert a record in parent. How do I do that, if I don't know the autonumber value of the record?

Many thanks for your help
Ilan


"Ilan Sebba" <ilan underscore sebba at btinternet stop com de***@yahoo.com> wrote in message news:ne********************@lnews.actcom.co.il...
I have a 'supertype' table with only one field: autonumber. Call this table
the 'parent' table. There are two subtypes, 'androids' and 'martians'. Martian have only one thing in common: they give birth to identical mules. So each android and a martian have primary key which is a foreign key to
the
parent table. Now, I want to insert a new record in 'android' or

'martian'.
This can be done easily using MS-Access forms. But I want to do so

using SQL. To add a martian, I first need the parent ID. How do I know what it is?

Here are my tables

tlbParent
Autonumber (PK)

tblAndroid
ParentFK (PK)
AndroidFields

tblMartian
ParentFK (PK)
MartianFields

tblMules
ParentFK
MuleFields

If I want to insert an Android, I need to first insert a record in parent. How do I do that, if I don't know the autonumber value of the record?

Sorry, but I fail to see why you need the parent table at all. Why not

just have AutomNumber PKs on each of the other tables? Are the fields in the other tables different from each other?
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 12 '05 #4

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

Similar topics

33
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and...
35
by: Traci | last post by:
If I have a table with an autonumber primary key and 100 records and I delete the last 50 records, the next record added would have a primary key of 101. Is there any way to have the primary key...
4
by: yf | last post by:
A KB article "http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells that the maximum number of records that a table may hold if the PRIMARY key data type is set to AUTONUMBER is...
26
by: jimfortune | last post by:
Sometimes I use Autonumber fields for ID fields. Furthermore, sometimes I use those same fields in orderdetail type tables. So it's important in that case that once an autonumber key value is...
8
by: petebeatty | last post by:
I have created a SQL string the properly inserts a record in the table. However, the insert does not occur at the end of the table. Instead it inserts a record after the last record that I viewed....
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
1
by: gtwannabe | last post by:
I'm having a problem with a form that uses AutoNumber as the primary key. I have an Abort button to delete the current record and close the form. If AutoNumber is assigned, the code executes a...
9
by: Tom_F | last post by:
To comp.databases.ms-access -- I just discovered, to my more than mild dismay, that some tables in my Microsoft Access 2003 database have duplicate numbers in the "AutoNumber" field. (Field...
6
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.