473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to check indices with other columns?

Adithya Adi
I have 2 tables.

Project and task

Project_Table:
prjct_id int, PK(identity Index)
prjct_name nvarchar(50),(unique index)
prjct_position int,(unique Index)

Task_table:
tsk_id int, PK
prjct_id int, (From Project_table)
tsk_name nvarchar(50),(unique Index)
tsk_position int

Say for eg., there are 5 projects, and each project consists of 10 - 12 tasks. Each Project have their positions(buttons) in a form(VB.NET). while clicking on a particular Project Buttons, This should go to respective tasks. (This is my Idea)

prjct_id in the task_table is not an unique index, because there is a necessity to enter 2 or more tasks in the table with the same project.

how can i create an unique index with the tsk_position which allows only index features within one project?

eg. project_table:
----prjct_id----prjct_name----prjct_position

-------1----------a1a1-----------101
-------2----------b2b2-----------121


task_table:
----tsk_id-----project_id------tsk_name-----tsk_position

------1-----------1--------------aaa------------1
------2-----------1--------------bbb------------2
------3-----------2--------------xxx------------1
------4-----------2--------------yyy------------2
------5-----------1--------------ccc------------3
------6 ----------1--------------ddd------------4

project_id in the task_table relates with the project_table.
There are 4 tasks for project - a1a1 with task_id - 1,2,5,6 and task_position - 1,2,3,4 respectively

There are 2 tasks for project - b2b2 with task_id - 4,5 and task_position - 1,2 respectively.

task_table:
----tsk_id-----project_id------tsk_name-----tsk_position

------7-----------2--------------zzz------------2
------8-----------1--------------eee------------3
(this should be wrong)
Because there is already a task in task_position - 2 for project (b2b2) which holds the project_id 2.

and the same case for the project 1 (a1a1) there is already a task in the position 3.

So could anyone help me out with this avoiding such type of duplications in SQL?
Jan 3 '12 #1
1 1609
ck9663
2,878 Expert 2GB
You can create multiple UNIQUE non-clustered index to a single table.

Happy Coding!!!


~~ CK
Jan 3 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Rustam Bogubaev | last post by:
Hi, I have a table with the following columns: ID INTEGEDR, Name VARCHAR(32), Surname VARCHAR(32), GroupID INTEGER, SubGroupOneID INTEGER, SubGroupTwoID...
1
by: Rupert Street | last post by:
Hi I have a form for staff to enter their work details into the Timesheet table that I have setup. I have included a combo box to select a client's ProjectNo from the Projects table selecting...
5
by: Mark Cave-Ayland | last post by:
Hi everyone, I'm trying to calculate an output column which is the difference of two other columns in the query output; the first column is an aggregate of items in stock, while the second...
1
by: Davy | last post by:
Hi all, I am using PythonWin from ActivePython. And I use the GUI button 'Check' to check the .py file. But the Check did not give out a check list. It just show "Check failed" or "Check...
1
by: Alex | last post by:
Hi all, I'm trying to get this example working with csharp in a winforms app... I'm creating a datasource and putting in a table that has 10 columns: cboxTeam.DataSource = cboxTeam_DS.Tables;...
2
by: mike | last post by:
I'm looking for an efficient way to populate derived columns when I insert data into a table in SQL Server. In Informix and PostgreSQL this is easily done using the "for each row..." syntax, but...
1
by: Drew | last post by:
Hello all, Does anybody know if it is possible to set the default value of a field to equal the concatenation of 2 other fields? I.E. Field 1 = 123 Field 2 = 345 Field 3 = (Field1 + Field2) =...
1
by: Manuel Jaen | last post by:
Hi everybody, I'm starting up with those generated columns of the DB2, but all the examples that I come up are simple, and as far as I've read the thing I want to do is not possible. Can someone...
2
bugboy
by: bugboy | last post by:
When i query a single column in a table do the total number of columns in the table affect the query speed? Or are unqueried columns simply ignored? I want to add a column to a table that won't...
1
by: aadsaca | last post by:
Hi there, I have three(3) columns on my ListView, now i want to know on how to add items to the 2nd and 3rd columns via codes. I am using Visual Studio 2005. Thanks, arjel
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
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,...

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.