473,809 Members | 2,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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/Relationaldesig n 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 2007

"Mikey" <ex************ ***********@ear thlink.net> wrote in message
news:2004120718 420752357%excep tionsTakeThisOu tDude@earthlink net...
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/Relationaldesig n 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/Relationaldesig n 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.co m> 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/Relationaldesig n 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
2531
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 of the "storage". The storage is a "box" where to make the objects persistent. It can be everything : a db, a file, ...
2
1735
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 Relational Feature, and it seems to be pretty creative, but it's also very limited towards any change. What I'm after is something similar to an interface in Java, but for tables in Oracle. Can you abstract out the interface to a table, i.e. what...
2
1370
by: object-relational persistence mapping | last post by:
Someone can tell me where I find a good Object-Relational Mapping library.
5
1850
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 doesn ice stuff, but none of them was really exactly what I was looking for. It need to be: - free (!!) - generates the code in VB.NET - doesn't use dll's, but generates just the code (!!) - preferably doesn't use stored procedures, but puts...
1
1605
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 relational mapper so far, apart from some home grown classes that implement simple Row to Object mappings. Now these classes are becomming difficult to maintain (I created them a year or so ago). So, I decided to switch to some properly...
3
6208
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 inheritance and very limited user defined types (I defined a UDT with 2 attributes and couldn't use it in a table, and the trainer said it must contain 1 attribute at most so that it can be used (as a column) in tables) So my question is whether...
1
1819
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
1558
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 problems. So: get an object-relational mapper: now you have 2**3 problems." That is to say I feel that they all make me learn so much about the internals and features of the
13
1618
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 is a facade initialized with a configuration file (XML). It provides callable command objects for each sql query. The call substitutes template variables with its parameters, and returns the result of the query. I would like to get some opinions...
0
9721
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, 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...
0
9602
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
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, 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...
0
10376
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 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...
1
10383
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,...
0
10120
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 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...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5550
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...
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.