Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

RE: Relationship

Discussion in 'Information Technology' started by Bassist, Oct 27, 2005.

Tags:
  1. Bassist

    Bassist
    Expand Collapse
    Guest

    Hi Hafeez.

    This is easy to do in an Access MDB, but harder in SQL Server.

    In Access, define a unique index on the field CableID, make sure Required is
    set to No and make sure there is no default value set.

    That way, Access will happily let you define new records with no CableID
    value, but also ensure that if you do enter a value, then it must be unique.

    The "gotcha" here is that most people forget to remove the Default Value if
    there is one, so if your foreign key field is numeric it defaults to zero. A
    unique index won't allow two zero values, but it will allow two null values.

    SQL Server is less forgiving of nulls, so if you're writing an Access
    Project it's harder to implement these optional-one-to-many relationships.

    Regards,

    "Hafeez Esmail" wrote:

    > Hi Sprinks,
    >
    > I've spent a lot of time trying to figure it out, and it pretty much boils
    > down to one question.
    >
    > I have a field "CableID" in a table. I want it to be limited to a list (in
    > another table), make it optional (so you don't have to enter something in if
    > you don't want to) and I want to ensure that there cannot be any duplicates,
    > but multiple records containing a blank "CableID" field is allowed.
    >
    > Example of something I want:
    > rec#, ........., CableID
    > 1 ............... A15
    > 2 ............... A16
    > 3 ...............
    > 4 ...............
    > 5 ............... A11
    >
    >
    > "Sprinks" wrote:
    >
    > > Hafeez,
    > >
    > > It is difficult to advise you based on what you've given us so far. Please
    > > post the structures of your tables and a generic description of what you're
    > > using the database application to do, and what kinds of inputs and outputs
    > > you want.
    > >
    > > Sprinks
    > >
    > > "Hafeez Esmail" wrote:
    > >
    > > > I'm trying to decide what the best relationship I should have. here's a
    > > > simplified analogy of what I have.
    > > >
    > > > 4 Possible combinations:
    > > > Cage is empty
    > > > Cage with ONE animal
    > > > Cage with ONE bowl
    > > > Cage with one animal AND one bowl
    > > >
    > > > There are several fields in each table.
    > > > Tables: Bowl, Cage, Dog, Cat, Bird etc..
    > > >
    > > > In the ANIMAL and 'Bowl' table, one of the fields is "Cage Number". "Cage
    > > > Number" is the primary key in the 'Cage' table.
    > > >
    > > > Not all animals belong in a cage (some are sold)
    > > > Not all bowls belong in a cage (some are in stock)
    > > >
    > > > What kind of relationship should I have between the tables (on the "Cage
    > > > Number" field) to ensure that only the four possible combinations listed
    > > > above can exist while keeping in mind that a form is need for data entry.
    > > > Any help would be muchly appreciated
    > > > TIA
     
  2. Loading...

    Similar Threads Forum Date
    Relationship with Creator Blogs Oct 17, 2015
    I'm open-minded about romantic relationships... how do I explain to family? Love & Marriage Aug 22, 2015
    Arts/Society What are your thoughts on the interaction of male / female relationship of marriage? Language, Arts & Culture Oct 15, 2013
    Relationship advice Love & Marriage Sep 30, 2012
    Need advice...Sikhi in relationships Love & Marriage Nov 17, 2011

Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page