Hi,
Do you guys know what's wrong with a one-to-one relationship?
The reason I want to make it like this is that at the very end of the chain,
the set of keys is huge. I want to limit the number of columns to be the
key. i.e. the [company] table has 1 column as the key. The [employee]
table will have 2 columns as the key.
e,g,
If I add a [sale] table to the [company]-[employee] relationship, the third
table
will have 3 columns as the key -- "company id", "employee id", and "sale
id".
(e.g.)
I have a company with many employees and computers. But instead of classify
all these, I just want to call all these as an entity. A company is an
entity. An employee is just another entity. etc.
So, instead of a one-to-many:
[company]---*[employee]---*[sale]
|
|
*
[computer]
I make it one-to-one.
[entity]---*[entity]
If I want to know the name and address of the entity "employee", I will have
a 1-to-1 table [employee] to look up the information for this employee
entity.
[entity]---*[entity]
|
|
[company]
|
|
[employee]
|
|
[computer]
|
|
[sale]
-- There is no answer. There has not been an answer. There will not be an answer. That IS the answer! And I am screwed. Deadline was due yesterday.
There is no point to life. THAT IS THE POINT. And we are screwed. We will run out of oil soon. 13 1699
>> I want to limit the number of columns to be the key. <<
You missed the whole point of a data model. It is supposed to reflect
reality, and not your wishes. If the entities have a key that is made
of (n) atributes, then you have to put the proper constraints in the
DDL. have a company with many employees and computers. But instead of classify all these, I just want to call all these as an entity. <<
Kind of like a small child who uses the word "THINGIE" for everything
in creation? Please read a book on data modeling before you code
anything.
"To be is to be something n particular; to be nothing in particular or
to be everythign in general is to be nothing at all" -- Aristotle
Hi,
So, you don't know why one-to-one relationship is bad.
"--CELKO--" <jc*******@eart hlink.net> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. . I want to limit the number of columns to be the key. << You missed the whole point of a data model. It is supposed to reflect reality, and not your wishes. If the entities have a key that is made of (n) atributes, then you have to put the proper constraints in the DDL. have a company with many employees and computers. But instead of classify all these, I just want to call all these as an entity. <<
Kind of like a small child who uses the word "THINGIE" for everything in creation? Please read a book on data modeling before you code anything.
"To be is to be something n particular; to be nothing in particular or to be everythign in general is to be nothing at all" -- Aristotle
Tom (no****@yahoo.c om) writes: Do you guys know what's wrong with a one-to-one relationship?
The reason I want to make it like this is that at the very end of the chain, the set of keys is huge. I want to limit the number of columns to be the key. i.e. the [company] table has 1 column as the key. The [employee] table will have 2 columns as the key.
And? I don't really understand where you're heading. Yes, you could
invent a superclass called entities, and make everything a heir of
that. Which maybe could make sense for some business problems, but
certainly not all. After all, you are in a relational database, not an
object-oriented one.
And I am not really sure what you mean with one-to-one relationship.
I would take that to mean that for every A there is always a B and
vice versa. I could think of having such a pair of tables if the
set of attributes for an item is huge, and some of them are referenced
far more often than others. But it does not seem like it's that you
are talking about. After all, most companies have more than one employee.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
Hi,
Someone hands me a spec that states the following:
1)
A Headquater can have zero or many companies.
A Company can have zero or many Stores.
A Store can have zero or many Departments.
A Department can have zero or many Services.
A Service can have zero or many Employees.
An Employee can generate many Sales.
2)
Each of these HQ, Company, Store, etc. can have their own Sales.
The Sale doesn't have to be come from an Employee.
By looking at (1), there is no problem. It is clear. The [Sale] table will
have 7 columns as the key.
However, this doesn't satisfy all (1) or (2). If they have a HQ by itself,
the [Sale] table will only have a "HQ id" and 5 empty columns, and finally a
"Sale id".
Another example is that they can have a Compay without a HQ and the Company
has one or two employees. The sales can be done either by the company or by
the employees. In this case, the [Sale] table will have only the [company
id], [employee id], and a [sale id]. The rest of the 4 columns will be
empty. If the sale is done only by the company, there will be 5 empty
columns.
Bottomline is that any of the combination can generate a sale.
Of course, this setup will not work at all.
I already have a way to do this.
I have a [Reference] table that has a reference number and the combination
of the HQ, Company, etc. I then use the Referernce Number and the Sale Id
as the key for the [Sale] table.
This works great but I am trying to think of something simplier (if any).
The very first thing that come to mind is to generalize these HQ, Company,
Employee, etc. to just "Entity". But this will require a One-to-One
relationship between the [Entity] table and the rest of the [HQ], [Company],
etc. tables. Unless I combine all the columns into one big [Entity] table.
"Erland Sommarskog" <es****@sommars kog.se> wrote in message
news:Xn******** **************@ 127.0.0.1... Tom (no****@yahoo.c om) writes: Do you guys know what's wrong with a one-to-one relationship?
The reason I want to make it like this is that at the very end of the chain, the set of keys is huge. I want to limit the number of columns to be the key. i.e. the [company] table has 1 column as the key. The [employee] table will have 2 columns as the key.
And? I don't really understand where you're heading. Yes, you could invent a superclass called entities, and make everything a heir of that. Which maybe could make sense for some business problems, but certainly not all. After all, you are in a relational database, not an object-oriented one.
And I am not really sure what you mean with one-to-one relationship. I would take that to mean that for every A there is always a B and vice versa. I could think of having such a pair of tables if the set of attributes for an item is huge, and some of them are referenced far more often than others. But it does not seem like it's that you are talking about. After all, most companies have more than one employee.
-- Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp
"Tom" <no****@yahoo.c om> wrote in message
news:xY******** *******@newssvr 27.news.prodigy .net... Hi,
So, you don't know why one-to-one relationship is bad.
Oh, no, he does. He just told you why.
What Joe has trouble with is social skills. :-)
"--CELKO--" <jc*******@eart hlink.net> wrote in message news:11******** **************@ g44g2000cwa.goo glegroups.com.. . I want to limit the number of columns to be the key. <<
You missed the whole point of a data model. It is supposed to reflect reality, and not your wishes. If the entities have a key that is made of (n) atributes, then you have to put the proper constraints in the DDL.
have a company with many employees and computers. But instead of classify all these, I just want to call all these as an entity. <<
Kind of like a small child who uses the word "THINGIE" for everything in creation? Please read a book on data modeling before you code anything.
"To be is to be something n particular; to be nothing in particular or to be everythign in general is to be nothing at all" -- Aristotle
I can tell. ;)
Just like that guy in Office Space.
"Greg D. Moore (Strider)" <mo************ ****@greenms.co m> wrote in message
news:3Y******** **********@news read2.news.atl. earthlink.net.. . "Tom" <no****@yahoo.c om> wrote in message news:xY******** *******@newssvr 27.news.prodigy .net... Hi,
So, you don't know why one-to-one relationship is bad.
Oh, no, he does. He just told you why.
What Joe has trouble with is social skills. :-)
"--CELKO--" <jc*******@eart hlink.net> wrote in message news:11******** **************@ g44g2000cwa.goo glegroups.com.. . >>> I want to limit the number of columns to be the key. << > > You missed the whole point of a data model. It is supposed to reflect > reality, and not your wishes. If the entities have a key that is made > of (n) atributes, then you have to put the proper constraints in the > DDL. > >>> have a company with many employees and computers. But instead of >>> classify all these, I just want to call all these as an entity. << > > Kind of like a small child who uses the word "THINGIE" for everything > in creation? Please read a book on data modeling before you code > anything. > > "To be is to be something n particular; to be nothing in particular or > to be everythign in general is to be nothing at all" -- Aristotle >
set of keys?
a primary key should always be a single column
always always always
one-one relationship ISN'T BAD you jsut need to know where to use it
use it to store salary information sometimes
use it if your table is super wide
use it for a couple of different reasons
Tom (no****@yahoo.c om) writes: Someone hands me a spec that states the following:
1) A Headquater can have zero or many companies. A Company can have zero or many Stores. A Store can have zero or many Departments. A Department can have zero or many Services. A Service can have zero or many Employees. An Employee can generate many Sales.
2) Each of these HQ, Company, Store, etc. can have their own Sales. The Sale doesn't have to be come from an Employee.
By looking at (1), there is no problem. It is clear. The [Sale] table will have 7 columns as the key. However, this doesn't satisfy all (1) or (2). If they have a HQ by itself, the [Sale] table will only have a "HQ id" and 5 empty columns, and finally a "Sale id".
Another example is that they can have a Compay without a HQ and the Company has one or two employees. The sales can be done either by the company or by the employees. In this case, the [Sale] table will have only the [company id], [employee id], and a [sale id]. The rest of the 4 columns will be empty. If the sale is done only by the company, there will be 5 empty columns.
Bottomline is that any of the combination can generate a sale.
Thanks for that supplementary information. That brought a whole more sense
into it.
I can think of a couple of ways to skin that cat. One is to add
dummy entries on all levels, so if the HQ performs a sale, that is
actually a dummy Employee at a dummy Service etc. That is probably messy.
Your idea of making all into entities is probably better, although I
would probably twist it a bit. The first four levels are an orginisational
hierachy, which should be one table, to permit for any number of
levels. What this service is, I don't know so I ignore it :-). Employees
could be tied to any level in the org-hiearchy. (Most HQs have a few
employees of their own.)
This could lead to sale be performed by an employee or a organisation,
which means that you only have two alternate keys in Sales, which might
be manageable.
Exactly which way to go, depends on the rest of the business domain.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alcyone Oliveira |
last post by:
------=_NextPart_000_000D_01C36572.F6480CE0
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_000E_01C36572.F6480CE0"
------=_NextPart_001_000E_01C36572.F6480CE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
|
by: Mike Sutton |
last post by:
Please let me know what you think of this scheme I have come up with
(not to imply that noone else has before me) for managing
relationships.
I have created an entities table with Individual and Organizational
subtypes. I need to be able to relate them to eachother (e.g., some
are customers of or suppliers to others, some have employer/employee
relationships,...). I know this is not an uncommon thing to do.
So, I have created...
|
by: Andante.in.Blue |
last post by:
Hello, I have just inherited a legacy Access 97 database. While going
through it, I noticed something strange... its Relationships window
(the one accessed by Tools --> Relationships) is almost empty.
Now, as I ponder how a relation database could work without any
relationships, I noticed that the queries of the database defined some
relationships between the source tables and queries. Which leads me
to the question, what is the...
|
by: Larry R Harrison Jr |
last post by:
I have an Access 97 database with 2 tables that have a one-many
relationship. I have a SQL statement in the "one" table which I want to
execute and insert 7 records into the "many" table, and I want them to be
linked to the "main" table.
Problem is, it won't let me run the SQL run as long as the one-many
relationship is established in the relationship window.
The SQL is:
|
by: francophone77 |
last post by:
I deleted a relationship in the relationship view, but when I create a
query that includes those two tables, the relationship reappears. When
I go back to the relationship view there is NO relationship but I can't
seem to get rid of it for queries (without manually doing it for each
query). Can anyone tell me whats going on??? TIA
| |
by: Joey Lee |
last post by:
Hi,
I have created a dataset schema(*.xsd) which contain two element
"InvoiceHeader" and "InvoiceDetail".
I set the primary key of both the element. for example "InvoiceHeader" -> id
and "InvoiceDetail" -> "id, date"
Then I created a relationship between both these item using the key "id".
This create the one-to-many relationship.
|
by: BrianDP |
last post by:
This is a strange one--
I have an Access 2K database with a split front end/back end. There
are two tables in the back end - RFile and RLine. There is a one to
many relationship from Rfile.Rnumber to Rline.Rnumber. Originally I
went in with the Relationships window, drew the line, and clicked the
cascading updates and deletes. Everything was fine, for a couple of
years.
All of the sudden however, this relationship seems to delete...
|
by: BuckBaxter |
last post by:
Recently had trouble creating a one-to-many relationship between Customer table and Order table. After drag & dropping the field CustomerNo (key) in Customer table to CustomerNo (foreign) in Order table, the relationship wizard would begin making a one-to-one relationship. After a lot of searching, I still don't know why the wizard thinks I want a one-to-one relationship or how to change that. However, when I deleted the field CustomerNo from...
|
by: Phil Stanton |
last post by:
Having spent ages sorting out the layout of my relationship window with
about 60 tables and getting it all tidy and with enough of the tables
visible to show the PK an FK relaionshipsOn a subseqent occassion, on
opening the relationship window, I found all the tables had shrunk so that
in most cases, only the table names were visible and the fields could only
be seen by "expanding" the table again.
I know you can print out the relationship...
|
by: NicoleCartrette |
last post by:
Going back to school is easier said than done..
This was posted to an older thread earlier but I don't think it got any attention. Your help is appreciated
Professor requires we create a simple database and specified what are to be the primary keys and relationships etc.
I have created the four tables and established the neccessary one to many and many to one relationships between primary keys in the tables with the exception of one...
|
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: 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: 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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |