473,799 Members | 3,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL tables question

I am looking to improve redundancy in a database. If I have several
different tables having identical child tables (design, not data) for
holding images, is it possible to have all these different tables
reference a single common child table to hold their images? If so, how
do I maintain referential integrity? I have thought about creating an
additional column in the image table called MasterTBL (beside ID,
MasterID & IMG) to hold the name of the table the image is associated
with, but this doesn't seem to be an option with Access' built-in
referential integrity methods (Access doesn't seem to be able to use a
table name as an integrity method).

Does anyone have any suggestions or on-line examples that I can look over?

TIA
...Geshel
--
*************** *************** *************** *************** ***********
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
*************** *************** *************** *************** ***********
“Anyone who believes in Intelligent Design (“creationism ”) is just as
ignorant and ill-educated as someone who believes that the world is
flat, that the Sun circles the Earth or that there really is a tooth
fairy. Darwinism has an overwhelming foundation of evidence that can be
tested and reproduced. Intelligent Design, on the other hand, has no
evidence at all; not one single shred of testable proof. As such,
Intelligent Design is Religious Mythology, and has no right whatsoever
to be in our Science classrooms.” - 99.99+% of Scientists
*************** *************** *************** *************** ***********
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.” Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
*************** *************** *************** *************** ***********
Nov 20 '05
11 1280
Well, I still think the other branch of this thread wasn't horrible advice
:P

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Jason Kester" <ja*********@gm ail.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .

First off, let me apologize for the asonishingly terrible advice you've
been getting in this thread. We're normally a bit sharper than this!
Maybe if you'd asked over in a SQL Server group...

But yeah, please don't simply abandon normalization and add TableName
to your Image table! There's a way out of this.

If you have a common base for all the tables that you need to hook
Images up to, you're could do something like:
Company
----
CompanyID
CompanyName, etc...
Customer
---
CompanyID
ShippingAddress , etc...
Manufacturer
---
CompanyID
ManufacturerSpe cificStuff...
So, you'd generate your IDs in Company, then reuse them in Customer of
Manufacturer. Essentially making Company the base class for Customer
and Manufacturer. No need to define a CustomerID, since it's
one-to-one with Company.

Then you can have a CompanyImages table that takes advantage of the
fact that CompanyID is unique across Company, Customer, Manufacturer,
Supplier, etc. Thus allowing your image table to look like:

CompanyImage
---
CompanyID
ImageID
One table to associate images to anything that has Company as its base.
Make sense? Just make sure that your sub-classes are actually related
to one another, or you're setting yourself up for and even sketchier
data-integrity nightmare than you would if you tried to cram everything
into a single table with a TableName column.

Good luck!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/

Nov 20 '05 #11
"Jason Kester" <ja*********@gm ail.com> wrote in message news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
Al Reid wrote:
Yes you can do it. Create a field named STID (source Table or something more to your liking). Store the name of the table in that field. Delete any primary key you currently have defined. In the Design View, select the new field and the old primary key field and on the toolbar, click the primary key button. You now have a composite key.

When you add the records, store the table name in the STID field. Include the STID in your table joins and queries.

I hope this helps,


Holy crap! Did you just say that out loud? That's a Terrible Idea!
Sure, you can build a system where your entire database fits into a
single table that way, but you're setting yourself up for a maintenance
nightmare! Just think about how you would need to set your foreign
keys up to handle this. You would essentially need to add STID onto
EVERY RECORD in EVERY TABLE INVOLVED:

CompanyID CompanyName TableName
1 Joes pizza "I'm from the Company Table"
2 Al pizza "I'm from the Company Table"
3 steve's pizza "I'm from the Company Table"
4 Jims pizza "I'm from the Company Table"

ImageID KeyID TableName
1 1 "I'm from the Company Table"
2 1 "I'm from the Company Table"
1 3 "I'm from the Shipping Table"
4 5 "I'm from the Shipping Table"
Please Please Please don't do this!
Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/

The OP asked for suggestions and I provided one. The OP can decide if there is a compelling reason to do what he is asking or if it
is wise to do it. The OP also stated that it could not be done in Access. I showed that it can be done.

I have worked on systems where the concept of using a single table to hold image or object data was employed. The nice thing about
it is that there are not multiple tables with identical structures holding like data. Having a single table that holds identical
data does not, in my opinion, make it any more difficult to maintain. One system (that I did not design) used a single "Objects"
table along with a single "mapping" table for all data base links. The Mapping table had columns for source table, source row,
destination table, destination row, link type and link description. This was the only table that included table names as a column.
At first I thought it was a terrible idea, but the beauty is that the same database schema can be ported to any relational database
without any changes whatsoever. In fact, the schema and data can be transferred, the connection string changed and it works. For
example, one can use the MSSQL DTS to copy the schema from Oracle to MSSQL, edit the connection string and run the application. No
other changes need to be made. Given that the goal was to have database independence, the design was reasonable, if not optimal.
Would I design it that way? Probably not. YMMV.

--
Al Reid
Nov 20 '05 #12

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

Similar topics

4
1653
by: Steve Klett | last post by:
(I posted this in ADO group, but I think this group will be better) Hi- I need to develop an FAQ section for our website. We would like to break up the FAQ by products, then categories with each category having n question/answer pairs. I would like to pass parameters in the querystring based on what the product/category the user selected, then populate a datagrid with the correct set of question/answer
15
2167
by: Gary Peek | last post by:
Can anyone tell us the browsers/versions that exhibit errors when tables are nested too deeply? And how many levels of nesting produces errors? (not a tables vs CSS question)
32
2732
by: Simon Dean | last post by:
Duh... Not another one... Hopefully simple though, I hate the way *I* (and it might be a CSS trait) can't intermix fixed width divisional elements with a variable auto expanding div??? The great thing I loved with Tables, was being able to say:
12
7023
by: nyathancha | last post by:
Hi, I have a question regarding best practices in database design. In a relational database, is it wise/necessary to sometimes create tables that are not related to other tables through a foreign Key relationship or does this always indicate some sort of underlying design flaw. Something that requires a re evaluation of the problem domain? The reason I ask is because in our application, the user can perform x
7
5099
by: cefrancke | last post by:
I have a few tables with sensitive user information (passwords, etc.) and I would like to prevent someone from opening a blank database and importing those tables. Is there a way to "hide" or protect these tables from being linked or imported? TIA
0
9546
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
10490
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
10260
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...
0
10030
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
9078
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 projectplanning, coding, testing, and deploymentwithout 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
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
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
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
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...

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.