Solved

Could you point how to deal with this intricated Relational Integrity when using MS-Access ?

Posted on 2016-08-23
16
30 Views
Last Modified: 2016-08-24
Hi Experts

Could you point how to deal with this intricated Relational Integrity when using MS-Access ?

Accordingly to
 img001
Three columns of tblBooks must have relational integrity with tblAutores at same time, but just one (AutorEncarnadoIndex)  or two(AutorEspiritualIndex and AutorEncarnadoIndex) must be filled at same time.

If only one of  the 03 columns has "0" value the a insertion could not be performed.

If the relational integrity isn't flagged  to all the 03 columns an author that is still been used in a not relationed column, it can be deleted.

Any suggestion?

Thanks in advance.
0
Comment
Question by:Eduardo Fuerte
  • 8
  • 8
16 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 41767736
From what I can understand, you need RI to the three columns in tblBook. Each Author index need to related to the Author index - correct?

In that case you must create three separate RI relationships. So you add the Author table three times and create a relationship to each of the three Author columns in your tblBooks.


Kelvin
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 41767741
In addition to my post above, you should not use a default of 0 for no value. RI accepts the use of NULL for columns with no value. 0 Implies that it is a value - which in this case it technically incorrect.


Kelvin
0
 

Author Comment

by:Eduardo Fuerte
ID: 41767850
Hi


So I put 03 copies of tblAutores, each one with a RI to one of the tblBooks columns.
Accordingly to:

img002
And changed the default values to null for the 03 columns in tblBooks.

If all the three columns in tblBooks are filled, Ok.

But if I fill just one column, the error arises (using C#).

img003
0
 

Author Comment

by:Eduardo Fuerte
ID: 41767856
Exception translated:

It's not possible to add ou modify register, since it's necessary it have a register related in tblAutores
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 41767869
Are you able to edit the row directly in Access? Are you running some sort of data layer between Access and C# (Entity Framework or similar)?


Kelvin
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 41767873
Can you also open tblBooks in design and check that the three Index values do not have required set to Yes.


Kelvin
0
 

Author Comment

by:Eduardo Fuerte
ID: 41768563
Hi


I'm using C# with OleDb - not using data layer.

I can edit the lines directly inside Access.

(The Access MDB file  is attached here, in case you want to have a look)
MasterFile.mdb
0
 

Author Comment

by:Eduardo Fuerte
ID: 41768566
... and the columns have the required clause set to no.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Eduardo Fuerte
ID: 41768581
and just in case, RI is fired when editing the line directly inside Acceess

(better MDB file)
MasterFile.mdb
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 41769203
If you can edit the records directly in the database exactly as you try via your application, then I believe that the problem lies in your application and not the database. I am not a C# developer, so have a limited ability to assist you here.


Kelvin
0
 

Author Comment

by:Eduardo Fuerte
ID: 41769227
@Kelvin

If I edit the line record directly in MS-Access the same error arises, so the problem isn't related to C# itself.
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 41769269
Ah, OK I'll check out your db shortly and advise
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 41769287
Database password?
0
 

Author Comment

by:Eduardo Fuerte
ID: 41769299
Sorry

lib2006
0
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 500 total points
ID: 41769320
OK, have edited the database. I removed all DEfault values from the fields in question - just leave blank for NULL. I have also edited the relationships diagram to remove duplicate relationships to these.
MasterFile.mdb
0
 

Author Closing Comment

by:Eduardo Fuerte
ID: 41769412
Perfect!

Thank you very much.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now