Hi,
Probably a very simple question but I'm afraid my experience at this is
somewhat limited so...
In a database with a many to one relationship, say orders to customers, is
it preferable to have an UID for a customer and store this in the orders
table rather than the customer name, for example.
CUSTOMERS
++++++++++
UID: Name: Address: Postcode: etc
01 Alpha 12 Acacia Ave HN7YHH
02 Beta 23 Acacia Ave HN6YTH
03 Gamma 28 Acacia Ave HN7UYH
ORDERS
Customer Amount date
Alpha 100 20030823
Alpha 250 20030824
Beta 90 20030825
Alpha 800 20030825
Gamma 1000 20030826
Or is it is better to have:
ORDERS
Customer Amount date
01 100 20030823
01 250 20030824
02 90 20030825
01 800 20030825
03 1000 20030826
Assuming that the second option is the best, how far do I go? I can see how
it would beof benifit to do this for orders and customers where there may be
several hundred thousand orders and hundreds of customers, but for example
would I need to do this for a customer contact database with titles - eg
each title having a UID and using this ID in the customer table?
Thanks for taking the time to read this. Any advice is gratefully received.
Kind thanks
Chris S 4 1680
"Chris Strug" <ho*****@solace 1884.com> wrote... Probably a very simple question but I'm afraid my experience at this is somewhat limited so...
Hi Chris: Yeah it is a little "basic" but you have to start somewhere...
In a database with a many to one relationship, say orders to customers, is it preferable to have an UID for a customer and store this in the orders table rather than the customer name, for example.
Definitely. The CustomerId is the primary key for CUSTOMERS so it would be
the foreign key in the ORDERS table. For a couple of reasons. It is
guaranteed to be unique which the customer name really isn't. While it may
be in the case of a company name (though there can be two "Starbucks"
entries) it most certainly wouldn't be if you were entering people's names.
Also it means you can change/modify a customer name without impacting the
ORDERS table.
Assuming that the second option is the best, how far do I go? I can see
how it would beof benifit to do this for orders and customers where there may
be several hundred thousand orders and hundreds of customers, but for example would I need to do this for a customer contact database with titles - eg each title having a UID and using this ID in the customer table?
Where to draw the line is always open for debate but you wouldn't typically
implement this for "titles" since a person is typically given a single
title. Admittedly it could be a compound title "President & CEO" but would
you want those listed seperately? It introduces problems for using the
database. When printing an envelope somebody has to ask "which of these
titles did you want to use?"
You would use the CustomerId to track multiple addresses perhaps. There is
a common need for a separate shipping address for instance. And the
CustomerId would be used if you were tracking the actual "contacts" like
mailings.
Tom
Tom,
Thanks for the reply.
The reason I ask is because I have been given a large SQL Server database to
manage. The database handles Containers and their movements in and out of
our facility. The main table has been set up as a many to one link between a
container table and a movement table. The PK in the containers table is an
eleven digit string which acts as a secondary key in the movements table (if
that makes sense!).
Keeping the integrity of the relationship isn't too much of an issue as a
container ID is a code determined by an ISO standard that has all kinds of
checksums in it to ensure it is unique. However, the movements table has
around 250,000 records in it linked to the container table with approx
75,000 records.
My thinking was that by identifying each container with a unique integer ID
and using this as the basis for the PK / SK, this would be quicker and more
efficient - after all I'm sure SQL server can handle an integer value faster
than a string.
Hence my question about titles - in a large customer table, would it make
sense to use a link to a titles table identified with an integer and store
this integer in the customer table as a secondary key? As I said, I think
that storing an integer is more efficient than storing a string?
Thanks for taking the time to read this - your help is greatly appreciated.
Kind thanks
Chris.
"Chris Strug" <ho*****@solace 1884.com> wrote... The reason I ask is because I have been given a large SQL Server database
to manage. The database handles Containers and their movements in and out of our facility. The main table has been set up as a many to one link between
a container table and a movement table. The PK in the containers table is an eleven digit string which acts as a secondary key in the movements table
(if that makes sense!).
Pretty much... I'm somewhat familiar with the container industry and I'm
working on something related. Is the e-mail address attached to your
message your actual e-mail address, we could chat out of the public eye?
My thinking was that by identifying each container with a unique integer
ID and using this as the basis for the PK / SK, this would be quicker and
more efficient - after all I'm sure SQL server can handle an integer value
faster than a string.
Personally I wouldn't worry too much about the efficiency of integers vs
strings. It takes whatever time it takes to do whatever it has to do and
you know it is operating faster this year than it was a couple of years ago.
And things will generally operate faster next year again without our direct
intervention.
That said I've been making it a point to establish a unique,
non-informational integer as a primary key in my tables. Again there are a
couple of reasons for it but the primary one is simply that I don't have to
look for a naturally occurring primary key. Additionally I make them unique
to the system. There isn't a pool for the containers and another pool for
the customers, there is simply one pool and everybody gets a key assigned
from it.
Hence my question about titles - in a large customer table, would it make sense to use a link to a titles table identified with an integer and store this integer in the customer table as a secondary key? As I said, I think that storing an integer is more efficient than storing a string?
If you needed to maintain a seperate list of "titles" for a customer then
yes I would reference a standard integer key. I wouldn't think of it as
"titles" per se but simply some data with a many-to-one relationship. In
your example it is a table of "titles" but you would use the same solution
regardless of what it was. That is why I prefer a non-information, integer
key that the system assigns.
By the way, in most cases no "user" ever sees these keys. They are
meaningless and each one is simply one larger than the previous one. There
is (just about) always a public "code" which is referenced by users. In
your example the user would key in (or select) the (it's called a BIC number
right?) container code.
Oh, the other advantage to using integers in this way is that (in the case
of systems that already exist) the client may have established customer
codes which they (and the customer) have been using for years. Having them
change to a number isn't likely to happen and they can continue to use the
codes they are familiar with. The code is looked up, the integer id is
determined and the system uses it internally for all other queries.
Tom
Tom,
Thanks for the taking the time to reply.
I'm a bit tied up at the moment (deadlines 'n all) but yes, the hotmail
account is valid - just swap the domain with the username. Please feel free
to drop me a line.
I'll come back to your post in a bit, but in the meantime, thanks again for
your help.
Cheers
Chris. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Don Vaillancourt |
last post by:
Hello all,
Over the years as I design more database schemas the more I come up with
patterns in database design. The more patterns I recognize the more I
want to try to design some kind of generic design patterns that can be
used and shared amongst many sub-schemas.
For example, the grouping of entities. I may have the following tables:
employee, product and client. These tables have no direct relationship
with each other. But...
|
by: WillieW |
last post by:
Hi folks,
I have Access 97 and have set up four tables, each with a Primary Key
with a file name manually entered. For example, the four tables relate
to information stored in a paper file, on four subjects, the paper file
is indexed WM/01/05. This number, a unique identifier in the database,
is the primary key and the same content in each table.
Table 1 is called "Driver Data"
Table 2 is called "Vehicle Owner"
|
by: zlst |
last post by:
Many technological innovations rely upon User Interface Design to elevate
their technical complexity to a usable product. Technology alone may not win
user acceptance and subsequent marketability. The User Experience, or how
the user experiences the end product, is the key to acceptance. And that is
where User Interface Design enters the design process. While product
engineers focus on the technology, usability specialists focus on the user...
|
by: Sally Sally |
last post by:
I have a very basic question on the two parameters shared buffers and
effective cache size. I have read articles on what each is about etc. But I
still think I don't quite grasp what these settings mean (especially in
relation to each other). Since these two settings seem crucial for
performance can somebody explain to me the relationship/difference between
these two settings and how they deal with shared memory.
Thanks much
Sally
...
|
by: MP |
last post by:
Greets,
context: vb6/ado/.mdb/jet 4.0 (no access)/sql
beginning learner, first database, planning stages
(I think the underlying question here is whether to normalize or not to
normalize this one data field - but i'm not sure)
:-)
Background info:
| |
by: |
last post by:
I was trying to display a report on a web page. I added a report object to
my project and dropped a report viewer control on the page. I assigned the
reportsource property in page_load, but I can't get anything to work.
(The closest I get is a login failure error. But when I generate the .rpt
file, I can get to the database without issue and this is all on the same
machine. And I can't find any properties to set that stuff on the...
|
by: Chocawok |
last post by:
Some of the classes in my app are graphical.
To encapsulate the graphical side of things I had created a class called
"sprite" which holds a bit map and knows how to draw itself etc.
The classes that are graphical contain a sprite object.
|
by: Steven |
last post by:
Hello All,
I am relatively new to database design and wanted to ask a few
questions to see if I am on the right track regarding design and
normalization.
I am creating a user entity which is made up of 4 tables:
User(UserID(PK), EmpID, CountryID, PostCodeID)
Employee(EmployeeID(PK), EmployeeType)
|
by: solargovind |
last post by:
Hi,
I am New to this forum. I need steps that i do in creating subform.
In main form, i have one table fields like vendor,account,due amount,balance amount and Requisition_id which is autonumber field.
I tried to create subform by using table or that table's form which are having autonumber field and this is to be linked with Mainform autonumber field(requisition_id).
But the following errors comes.
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |