473,396 Members | 1,963 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.

Many-Many vs Object Relational

Hi all. In the process of trying to figure this thing out, I've been
doing the old "stand around in the store and read as much as possible
before you look like a derelict" thing. This time, with the O'Reilly
"Managing and Using SQL" (I think that's it).

Anyway, I was looking at a chapter discussing database design (without
any direct reference to impementations in MySQL), and they mention
Obj/Relationaldesign as a way to have a many-to-many relationship. I'm
wondering if they're trying to imply that there are different ways to
implement a many to many. In my bkgnd, I would assume that in any
many-to-many you have to have the joining table, and there's not much
else to do but go to it and select all the rows that have the key
you're interested in.

This is why I'm looking for books... I assume that there's some
MySQL-specific "flavor" to design that I'm unaware of.

--
"It's beyond my ken... and my Barbie, and all of my action figures."

Jul 20 '05 #1
3 1984

"Mikey" <ex***********************@earthlink.net> wrote in message
news:2004120718420752357%exceptionsTakeThisOutDude @earthlinknet...
Hi all. In the process of trying to figure this thing out, I've been
doing the old "stand around in the store and read as much as possible
before you look like a derelict" thing. This time, with the O'Reilly
"Managing and Using SQL" (I think that's it).

Anyway, I was looking at a chapter discussing database design (without
any direct reference to impementations in MySQL), and they mention
Obj/Relationaldesign as a way to have a many-to-many relationship. I'm
wondering if they're trying to imply that there are different ways to
implement a many to many. In my bkgnd, I would assume that in any
many-to-many you have to have the joining table, and there's not much
else to do but go to it and select all the rows that have the key
you're interested in.

This is why I'm looking for books... I assume that there's some
MySQL-specific "flavor" to design that I'm unaware of.

--
"It's beyond my ken... and my Barbie, and all of my action figures."


Hi Mikey,

Even with MySQL there is only one way to implement a M:M relationship. It is
pretty tradtional:

A Project employs many Employees
An Employee works on many projects.

RDMS (including MySQL) can only do binary relationships. So you get the
following

Table Employee
*EmpID
EmpName

Table Project
*ProjectID
ProjectName

Table Assignments
*ProjectID
*EmpID

This is the only way you can do this correctly. And this is not
implementation specific. It works, and has worked since 1970. Many to Manys
resolve in a table where the combination of both keys are unique. And you
can even add attributes to this relation.

Best Regards,

Rich
Jul 20 '05 #2
Mikey wrote:
Anyway, I was looking at a chapter discussing database design (without
any direct reference to impementations in MySQL), and they mention
Obj/Relationaldesign as a way to have a many-to-many relationship. I'm
wondering if they're trying to imply that there are different ways to
implement a many to many. In my bkgnd, I would assume that in any
many-to-many you have to have the joining table, and there's not much
else to do but go to it and select all the rows that have the key you're
interested in.


I'll probably get in trouble with O-R purists for saying this, but I
believe in practice, object-relational is an abstraction of well-known
relational concepts.

You could have an O-R model in which your primary table is a collection
of objects, and each of these objects has an attribute which is a
reference to another collection, the set of objects in the second table
related to this primary object. In that way, a many-to-many
relationship can be abstracted and represented in an object-oriented way.

So for example, you have a table of Employees, and each employee object
has a method getProjects(), which returns a subset of objects from the
Projects table. Likewise, each Project object has a method
getEmployees(), which returns a subset of objects from the Employees
table.

The physical storage behind this abstraction is likely identical between
O-R and plain relational; there's a join entity that references both the
Employees table and the Projects table. The O-R mapping just allows you
to fetch the matching rows without knowing having to know about the join
entity in the middle.

Regards,
Bill K.
Jul 20 '05 #3
On 2004-12-07 21:15:42 -0500, Bill Karwin <bi**@karwin.com> said:
Mikey wrote:
Anyway, I was looking at a chapter discussing database design (without
any direct reference to impementations in MySQL), and they mention
Obj/Relationaldesign as a way to have a many-to-many relationship. I'm
wondering if they're trying to imply that there are different ways to
implement a many to many. In my bkgnd, I would assume that in any
many-to-many you have to have the joining table, and there's not much
else to do but go to it and select all the rows that have the key
you're interested in.


I'll probably get in trouble with O-R purists for saying this, but I
believe in practice, object-relational is an abstraction of well-known
relational concepts.

You could have an O-R model in which your primary table is a collection
of objects, and each of these objects has an attribute which is a
reference to another collection, the set of objects in the second table
related to this primary object. In that way, a many-to-many
relationship can be abstracted and represented in an object-oriented
way.

So for example, you have a table of Employees, and each employee object
has a method getProjects(), which returns a subset of objects from the
Projects table. Likewise, each Project object has a method
getEmployees(), which returns a subset of objects from the Employees
table.

The physical storage behind this abstraction is likely identical
between O-R and plain relational; there's a join entity that references
both the Employees table and the Projects table. The O-R mapping just
allows you to fetch the matching rows without knowing having to know
about the join entity in the middle.


Thanks, guys. Super, another mystery solved.
--
"It's beyond my ken... and my Barbie, and all of my action figures."

Jul 20 '05 #4

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

Similar topics

1
by: Roberto Gerola | last post by:
Hi, I've developed for our PHP projects a little object persistence library. Tha main goal of the library is to speed up the management of the data stored in a db. It is based on the concept...
2
by: MG | last post by:
Hi, I am interested to know if there are any features in Oracle that would allow a design similar to the "design by contract" methodology that exists in the OO world. I read about the Object...
2
by: object-relational persistence mapping | last post by:
Someone can tell me where I find a good Object-Relational Mapping library.
5
by: DraguVaso | last post by:
Hi, I'm ne to this subject, and has been looking around for some software that does the Object-Relational-Mapping, and generates the Data Access Layer. I found alreaddy a lot of application that...
1
by: mirnazim | last post by:
Hi, I have to develop a web based information system for an educational institution. It is going to be a 100% OO code. Therefore I also need an Object Relational Mapper. I have not used any object...
3
by: Robert Abi Saab | last post by:
Hi everyone. I just finished a course on PostgreSQL and I found out that PostgreSQL doesn't provide any object relational features (as claimed in the official documentation), except table...
1
by: PabloChristian | last post by:
I can`t use object types in Forms, how can I do to reference my object relational implementation in database
17
by: Aaron Watters | last post by:
I've been poking around the world of object-relational mappers and it inspired me to coin a corellary to the the famous quote on regular expressions: "You have objects and a database: that's 2...
13
by: sulyokpeti | last post by:
I have made a simple python module to handle SQL databases: https://fedorahosted.org/pySQLFace/wiki Its goal to separate relational database stuff (SQL) from algorythmic code (python). A SQLFace...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
Oralloy
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,...
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
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,...

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.