Hi,
I can imagine this question has been brought up before but I've spent all
morning trying to find what I need on google without success.
My application sits on Mysql or MS sql server engines and to date I've just
been using auto-incremental int64 fields to generate my RecID field.
I know that in the future the database will need to support multiple sites,
so theres also a SiteID field in there too.
example table ABC
Primary Key = (int64)ABC.RecI D + (int32)ABC.fk_S ites_RecID
In the not too distant future multi sites WILL be needed, so I need to
switch out auto-incrementation and generate record ids myself so that the
sites can be synchronised across to a central server (another noob terror to
come)
I don't want to use triggers or stored procedures as I want my database to
be as simple/clean as possible.
How should I generate my "autoincrementa l" unique RecIDs please?
thank you 5 4032
On Mar 17, 2:38 pm, "Claire" <claire@no_hope .comwrote:
Hi,
I can imagine this question has been brought up before but I've spent all
morning trying to find what I need on google without success.
My application sits on Mysql or MS sql server engines and to date I've just
been using auto-incremental int64 fields to generate my RecID field.
I know that in the future the database will need to support multiple sites,
so theres also a SiteID field in there too.
example table ABC
Primary Key = (int64)ABC.RecI D + (int32)ABC.fk_S ites_RecID
In the not too distant future multi sites WILL be needed, so I need to
switch out auto-incrementation and generate record ids myself so that the
sites can be synchronised across to a central server (another noob terror to
come)
I don't want to use triggers or stored procedures as I want my database to
be as simple/clean as possible.
How should I generate my "autoincrementa l" unique RecIDs please?
thank you
Look into UUID
Having a primary key that is the sum of two integers could get you in a lot
of trouble, since there are many combinations of two integers that could add
up to the same number. But in general, you would need to get the SQL MAX(ID)
from the table, increment by 1, and that would be your next id integer.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
"Claire" wrote:
Hi,
I can imagine this question has been brought up before but I've spent all
morning trying to find what I need on google without success.
My application sits on Mysql or MS sql server engines and to date I've just
been using auto-incremental int64 fields to generate my RecID field.
I know that in the future the database will need to support multiple sites,
so theres also a SiteID field in there too.
example table ABC
Primary Key = (int64)ABC.RecI D + (int32)ABC.fk_S ites_RecID
In the not too distant future multi sites WILL be needed, so I need to
switch out auto-incrementation and generate record ids myself so that the
sites can be synchronised across to a central server (another noob terror to
come)
I don't want to use triggers or stored procedures as I want my database to
be as simple/clean as possible.
How should I generate my "autoincrementa l" unique RecIDs please?
thank you
No, Im sorry if my shorthand is wrong Peter
I meant there are 2 fields in the primary key. (Im not daft enough to add
the values together)
1) 64 bit integer RecID field
2) 32 bit integer fk_Sites_RecID (foreign key, Sites table, RecID field)
but thank you for the MAX(ID) suggestion :)
Claire
"Peter Bromberg [C# MVP]" <pb*******@yaho o.NoSpamMaam.co mwrote in message
news:21******** *************** ***********@mic rosoft.com...
Having a primary key that is the sum of two integers could get you in a
lot
of trouble, since there are many combinations of two integers that could
add
up to the same number. But in general, you would need to get the SQL
MAX(ID)
from the table, increment by 1, and that would be your next id integer.
>How should I generate my "autoincrementa l" unique RecIDs please?
>
Look into UUID
Thank you for the UUID suggestion :)
I have to stick with my incremental big ints as they're more likely to be
compatible over a selection of different servers than guid/uuids. (ie the
version of MySQL I'm using doesnt support them)
Claire
On Mar 18, 1:21 pm, "Christophe r Van Kirk"
<chris.vank...@ fdcjapan.comwro te:
There is a problem with UUID, though. They're huge, especially when
converted to a string form.
<snip> http://en.wikipedia.org/wiki/UUID
<extract>
In its canonical form, a UUID consists of 32 hexadecimal digits,
displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for
a total of 36 characters... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: flupke |
last post by:
Hi,
i create my GUIs mainly via wxGlade. However when you start of to
program and want to do some rearranging to the gui, wxglade overwrites
your file and you've got to put your own code back in.
I think i can work around that (at least a bit) by making a second file
that imports the gui generated by wxglade and make classes that extend...
|
by: Justin Lebar |
last post by:
Sorry about the huge post, but I think this is the amount of
information necessary for someone to help me with a good answer.
I'm writing a statistical analysis program in ASP.net and MSSQL7 that
analyzes data that I've collected from my business's webpage and the
hits it's collecting from the various pay-per-click (PPC) engines.
I've...
|
by: Stan |
last post by:
Is it possible to hash a 100 bytes string to a integer? I found a few .NET
classes for that
such as Sha1Managed.ComputeHash but they return bytes. I am just not sure
about the idea of converting 100 bytes to four or eight without loosing
uniqueness.
The issue has come up because I am storing bills with customers in database
and I would...
|
by: Mark |
last post by:
BEGINNER QUESTION
I have a table which has a compound primary key consisting of two columns.
One of these columns is a foreign key which is generated in another table by
an identity.
I want to be able to generate the other primary key column value
automatically when an insert occurs but assume that I cannot use an identity
because it...
|
by: Poul Møller Hansen |
last post by:
I have made a stored procedure, containing this part for generating a unique
reference number.
SET i = 0;
REPEAT
SET i = i + 1;
SELECT RAND()
INTO reference
FROM SYSIBM.SYSDUMMY1;
SET p_reference = ref_prefix || SUBSTR(CAST(reference AS CHAR(12)),3);
| |
by: Willem |
last post by:
Based on MK's TSI_SOON (http://www.trigeminal.com/)I've created a
nifty little procedure that - whenever you compact you db you get an
incremental backup copy.
Given that you have a table with version information you get
incremental backups on a per-version basis.
SEE CODE BELOW
Basic idea is: start TSISOON with the options:
1. "compact...
|
by: Benjamin Smith |
last post by:
I have two tables like following:
create table attendancereport (
id serial unique not null,
staff_id integer not null references staff(id),
schoolyear varchar not null references schoolyear(year),
students_id integer not null references students(id)
);
// schoolyear.year in format "2003 - 2004".
|
by: Simon Wittber |
last post by:
I'm building a web application using sqlalchemy in my db layer.
Some of the tables require single integer primary keys which might be
exposed in some parts of the web interface. If users can guess the next
key in a sequence, it might be possible for them to 'game' or
manipulate the system in unexpected ways. I want to avoid this by...
|
by: Lennart |
last post by:
We have recently moved a ClearQuest database to db2 V8 on linux. We
take a full compressed backup on sundays (~400Mb) and compressed
incremental/incremental delta other weekdays. What puzzles me is that
despite low activity in the database, the delta backups are the same
size as the full backups.
Using db2look I've found that there is a...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |