I don't know what this concept is called... something about uniqueness

Let's say I have a single table of maintenance tasks. The table will have the following columns:
auto incrementing index
task_name
step_number
step_name
So, each task will have a series of steps to complete it. I want to make sure that the step_numbers are not duplicated within a given task. Of course, one way to solve this would be to have a separate table for each maintenance task, which would only hold records for each step. But I don't know the number of different tasks, and will likely be adding more and more, so adding a new table each time doesn't make sense. So, is this "uniqueness" something that I would have to check on the client side before updating, or is there a way to create a database constraint such as this. Oh, and if this concept has a specific name, I would appreciate hearing it.

Well, then let's break down Centinul's response some.
Normalization - see the wiki: http://en.wikipedia.org/wiki/Database_normalization
His 'tasks' table uses a task_id as the primary key; can also be known as a surrogate key. The 'task_name' column is now just data. If you want to change the 'data' you can change it without affecting the relations between the tables. Change it to anything you want, as often as you want; it is just data. If you make 'task_name' the primary key you 'lock it in' and then it becomes part of the table-to-table relationship. Worse the task_name value would need to be duplicated in the task_steps table; you can't change it easily in either table because the tables are linked together.
The 'tasks' table becomes a master table of all possible tasks with one record for each task.
CREATE TABLE tasks
( task_id   NUMBER        PRIMARY KEY
, task_name VARCHAR2(255) NOT NULL
);His 'steps' table is, similar to the tasks table, a master table of all possible steps with one record for each possible task. There is no information in this table about what task a step belongs to. A step might be part of several tasks, or part of no tasks at all. As with the tasks table the step_id is just a number to make the records unique; it might be assigned a value using a sequence generator (Oracle sequence). The numbers don't have to be consecutive, can be positive, negative, include decimal values; the only requirement is that they are unique within the table.
The step_name now becomes just a piece of data. Feel free to change the name whenever you like. The new name will show up in new queries but it won't affect the relationship between tables.
CREATE TABLE steps
( step_id   NUMBER        PRIMARY KEY
, step_name VARCHAR2(255) NOT NULL
);Now the part that can look confusing at first. His task_steps table is known as an intersect table. It 'intersects' the tasks table and the 'task steps' table. The records in this table are what associates a step in the step table with a task in the tasks table.
To tie the two tables together he has added a 'task_id' column to reference a record from the tasks table and has added a 'step_id' column to reference a record from the steps table. Each corresponding REFERENCES clause tells Oracle to enforce this relationship. So you CANNOT add a record with a task_id value that does not exist in the tasks table. And you CANN"OT add a record with a step_id value that does not exist in the steps table.
But, you said that you want each step that is associated to a task to have a number from 1 to n; this means that each task will have a step one.
So Centinul added a 'step_order' column; this is the same as what you referred to as 'step_number' so you could use your name if you like. The UNIQUE CONSTRAINT on task_id and step_order tellsl Oracle that the combination of these two values MUST BE UNIQUE within the table. Oracle still doesn't care what the values are as long as they are unique. You can have step_order values of 2, 6, -1 and Oracle won't care; that is a business rule that Oracle won't enforce without more help.
{code}
CREATE TABLE task_steps
( task_id NUMBER NOT NULL REFERENCES tasks(task_id)
, step_id NUMBER NOT NULL REFERENCES steps(step_id)
, step_order NUMBER NOT NULL
, CONSTRAINT task_steps_pk PRIMARY KEY (task_id, step_id)
, CONSTRAINT task_steps_uk UNIQUE (task_id, step_order)
{code}
He gave you the best example possible for what you want to do.
To add a record to the task_steps table:
1. select a record that already exists from the tasks table and use the task_id value of that record
2. select a record that already exists from the steps table and use the step_id value of that record
3. determine the largest value of step_order that already exists in the task_steps table, add 1 to it, and use the new value for step_order for the new record.
Step #3 is the tricky part since there may be several users or processes trying to add records at the same time. This is why this business rule is often only used for applications such as INVOICE and LINEITEM wher the same process creates the parent (INVOICE - task for your example) and all of the LINEITEM (task_steps) records at the same time.
Does that help explain what Centinul was suggesting?

Similar Messages

  • I have set up a new itunes library and am trying to sync this with my iphone.  My iphone is asking for an 'exchange' password.  I don't know what this is or where to find it.

    I am trying to sync my iphone with a new itunes library.  The iphone is askin for an 'exchange' password.  I don't know what this is or where to find it.

    Sounds like you do have an Exchange account setup on your phone. Have a Gmail or Hotmail account? They can both be setup as Exchange accounts. Have a work email account?

  • Updating ipod touch to os5.1  got an error message "cannot connect the ipod touch because the pairing record is missing"   don't know what this means or how to fix but am stuck, only option is to answer ok and close the error box.  Any ideas?

    Updating ipod touch to os5.1  got an error message "cannot connect the ipod touch because the pairing record is missing"   don't know what this means or how to fix but am stuck, only option is to answer ok and close the error box.  Any ideas?

    #1
    - Try another cable. The cable for 5G iPod (lightning connector) seems to be more prone to failure than the older cable.
    - If a 5G iPod               
    Iphone 5 lightning port charging problem - SOLUTION!
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Make an appointment at the Genius Bar of an Apple store.
      Apple Retail Store - Genius Bar
    #1.1 n/a because the errror message overrides it
    #2 see #1
    #3 iOS: Device not recognized in iTunes for Mac OS X
    But could be caused by #1
    #4 Covered by previous ones
    #5 Obvious jpegs are photos and thus will not sync as videos. Also see:
    iTunes: May be unable to transfer videos to iPhone, iPad, or iPod
    iTunes: Frequently asked questions about viewing and syncing videos
    #6 iOS: If you can't back up or restore from a backup in iTunes
    First #7 See #6
    Second #7 You have so many other problems resolve those first
    #8 Resolve other problems first

  • HT1338 When I try to download the iMovie Update :  "You have updates available for other accounts.  To update this application, sign in to the account you used to purchase it." shows -don't know what other accounts it is talking about? I Only have 1 Apple

    When I try to download the iMovie Update :
    "You have updates available for other accounts.
    To update this application, sign in to the account you used to purchase it." shows -but I don't know what other accounts it is talking about? I Only have 1 Apple Id !

    Maybe this will help. If you monitor the "More Like This" box, other solved threads appear. Opening them usually displays other threads.
    http://support.apple.com/kb/TS4236

  • Hello, alot of my space taken up on my ipod nano is listed under (other) I don't know what this is but it sure takes up most of the space on my ipod. Does anyone know what (Other) refers to and how to remove it.?Thx

    Hello, alot of my space taken up on my ipod nano is listed under (other) I don't know what this is but it sure takes up most of the space on my ipod. Does anyone know what (Other) refers to and how to remove it.?Thx

    Hello Norman,
    Welcome to the Apple Support Communities. To find out what the Other section is on your iPod Nano, the following will explain what the Other section is all about.
    Understanding capacity on iPhone, iPad, and iPod
    http://support.apple.com/kb/HT1867
    Once that is complete, then check the appropriate sections to see what is there. If you cannot isolate the issue then you may need to restore the iPod Nano. The following will assist with the restore process.
    Restoring iPod to factory settings
    http://support.apple.com/kb/HT1339
    Regards,
    -Norm G.

  • TS2966 My ipod has deleted all the music but has now gained 7.4mb in 'other'. I don't know what this is and want my music back on it. Help?!

    I have plugged in my ipod into my windows computer, scanned and fixed it (which was recommended), now when I tried to sync it again, I couldn't because the memory was used up with 'other'. I don't know what this is and how I can get rid of it, I have no music, films, photos, contacts on it, so am completely stuck! Help me please!

    A large amount of other usually signals corrupt software and/or files that were synced to the device.  You'll need to restore the iPod via iTunse to reduce it down to a much much smaller size.
    B-rock

  • Message says website under construction and that I should replace index htm. I don't know what this means or what to do.

    My website gives a message that it is under construction and says to replace index htm. I don't know what this means and I don't know what to do.

    iWeb has two ways to publish a website - via FTP to the root folder on a server or to a local folder...
    http://www.iwebformusicians.com/iWeb/Publish-Website.html
    With either method, two items are produced - an index.html file and folder with the same name that you gave the site in iWeb.
    When a visitor enters the URL - http://www.domain-name.com/ - this opens the index.html file which, in turn, opens the Home or Landing Page of the site. Without this file nothing will happen.
    If you are attempting to upload your files using the iWeb FTP, try using the settings shown in the first example on the above mentioned page. Leave the Directory/Path field blank so that the files are uploaded to the root folder.
    If you are using an FTP application you need to know the name of the root folder so that you can upload the index.html file and website folder to it. If you are in doubt, ask your hosting service what that is. My own hosting service allows me to create and name the root folder(s) but most others require that you upload to a "public_html" or "www" folder which seems kind of backward to me!
    Find out more about URLs and FTP here...
    http://www.iwebformusicians.com/iWeb/URLs-Favicons.html
    .. and here...
    http://www.iwebformusicians.com/Search-Engine-Optimization/Upload.html
    "I may receive some form of compensation, financial or otherwise, from my recommendation or link."

  • HT3275 Time machine error, backup disk image "/volumes/data-1/.sparesbundle " already in use. I don;t know what this means, can someone help?

    My Mac mini time capsule is showing an error Time machine error, backup disk image "/volumes/data-1/.sparesbundle " already in use. I don;t know what this means, can someone help?

    I had a similar problem and I solved it as follows -
    In Time Machine - > I deselected time capsule Data Disk as a destination.
    Then I pulled the power plug on the Time Capsule, twiddled my thumbs for 15 secs, plugged the power back in.
    Went back t Time Machine -> Re-Added the Time Capsule Data Disk as destination. And then tested by selecting Backup Now.
    All went well and the backup picked up from before the problem.
    BTW - I also have a USB drive connected to Time Capsule that is an alternate disk for Time Machine to backup.
    In Mountain Lion the GUI lets you add more than one Time Machine backup destinations very easily so I think it a good idea to have redundancy.
    Hope this helps.

  • Does anyone know how to permanently remove a device that is trying to pair with my computer? I don't know what this device is or where it came from. I just want it gone. Thanks

    Does anyone know how to permanently remove a device that is trying to pair with my computer? I don't know what this device is or where it came from. I just want it gone. This is the name of the device ArbAx6h2P6.

    If it's a bluetooth device:
    Bluetooth: How to delete a paired device:
    http://support.apple.com/kb/ta27116

  • I keep getting alerts every few seconds from Facebook saying: "exited?"  Wants to access your private information and friends list...... I don't know what this is so I keep clicking don't allow but it still keeps popping up every few seconds? What is this

    I Keep getting alerts from Facebook that pop up on my phone every few seconds saying: "exited?" Wants to access your friends list and profile info..... I always click don't allow because I don't know what this is but it still pops up. How do I stop this from happening?

    PORT YOUR NUMBER OUT...T MOBILE WILL PAY YOUR ETF IF YOU GIVE THEM YOUR VERIZON PHONES.

  • How do I connect my MacBook Pro to a projector? I don't know what my port is called.It has 3 rows of 8 pins???

    How do I connect my MacBook Pro to a projector?  I don't know what my port is called. It has three rows of 8 pins???

    MacBook Pro (15-inch Core 2 Duo): External ports and connectors
    http://support.apple.com/kb/HT2541
    Connecting an External Display or Projector To connect an external display orprojector with a DVI connection to your computer: 1 Turn on the external display or projector . 2 Make sure the display cable is connected to the external projector or display. 3 Connect the display cable to your MacBook Pro . Your MacBook Pro automatically detects the external display. 4 Adjust the resolution on the external display by using the Displays pane of System Preferences or the Displays status menu in the menu bar.
    http://manuals.info.apple.com/en_US/MacBook_Pro_Users_Guide.pdf

  • HT4009 Hi I purchased a game app for my daughter (6 years) and noticed 2 charges of £20.98 off this app she doesn't know and I don't know what this is for as it was a free app.

    Hi I purchased a game app for my daughter (6 years old ) littlest pet shop and been charged for 2 bills of £20.98 she doesn't know and I don't know how this has happened as it was a free app ?

    Hi
    Alot of free apps offer in app purchases which has probably happened here, things for extra points scores etc etc are offered for prices which is how the app can afford to be free via the charge in other purchases within the game.
    These are the sorts on in app purchases in littlest pet shop may have been one of these?
    If you are 100% sure that no purchse was made get in touch with apple they should be able to tell you what was purchased and when then you can take it from there?
    Hope this helps

  • I have downloaded and installed Adobe Flash Player, but it was installed to a "disk image".  I don't know what this is and I cannot see anything that requires Flash Player.  What am I doing wrong?

    I have downloaded and installed Adobe Flash Player, but it was installed to a "disk image".  I don't know what that is, but I cannot view anything that requires flash player.  What am I doing wrong?

    Thanks for your help, but that didn't do any good either.  I have been double clicking from the download files, double clicking on the "install adobe flash player", closing the anti virus, closing Safari, watching the install progress and clicking finish.  It indicates that "flash player" is installed, but every time I try to view something requiring flash player, it tells me I must download it.  It shows up in the "system preference"  and from there I can make some changes, but it still won't let me view anything requiring "flash player".   It does not show up in my apps like Adobe Reader does.  It shows up in the "downloaded files" section of "Finder".  I'm getting really perplexed over my inability to get this right.

  • I cannot sync my ipad photos to itunes on Windows 7 because it can't find   a "new folder." I don't know what this means. How to fix it?

    I can't sync my ipad photos to windows itunes in Windows 7 because it can;t find a "new folder" How do I fix this?

    It's not entirely clear to me, but I assume that you are trying to copy photos from the iPad to your computer (as opposed to syncing photos from your computer to the iPad), possibly using the windows camera wizard ? If so then the message is saying that it can't find a folder called 'New folder' on your computer which is presumably where it copied the last set of photos to (?). I don't use the wizard to copy the photos from iPad (I do it manually via windows explorer) so I don't know how it works, but aren't you able to tell it to copy the photos to a different folder on your computer other than one called 'new folder' ?  This page gives basic info for copying photos from the iPad to your computer http://support.apple.com/kb/HT4083 (it is not done via iTunes).
    If you want to copy photos to the iPad from your computer then there are instructions on this page http://support.apple.com/kb/HT4236 - that is done via iTunes using the Photos tab on the right-hand side of iTunes when you've selected the iPad on the left-hand side of it

  • Hi, I've got 5gb of 'other' content on my iphone and i don't know what this is or how to remove it?

    Just had my library transferred to a new PC, attempted to sync my iphone with itunes and there seems to be 5gb of 'other' content on my iphone?  I can't work out what this is, or how to manager/reduce it?

    I suspect you need to backup and then restore the device as this is generally the only way to clear up such data.
    Your library should contain all the media that is on the device. If for some reason that isn't so see Recover your iTunes library from your iPod or iOS device.
    tt2

Maybe you are looking for