Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7413241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:39:55+00:00 2026-05-29T06:39:55+00:00

i have a table in sql that uses the adjacency model to create child/parent

  • 0

i have a table in sql that uses the adjacency model to create child/parent relationship. here is the exact schema:

id int primary key identity(1,1)
name nvarchar(max)
parent int

now i want to have exactly one name with the same parent. another word for parent 1 there should only be one name. if that name wants to show up in another record, it must have a different parent. how can i do this in t-sql?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:39:56+00:00Added an answer on May 29, 2026 at 6:39 am

    I think you’re looking for unique constraints. This will allow you to define column combinations for which the data must be unique across the table, but are not part of the primary key.

    Are you using SQL Server? If so, these two articles should help:

    Overview: http://msdn.microsoft.com/en-us/library/ms191166.aspx

    Creating/modifying: http://msdn.microsoft.com/en-us/library/ms177420.aspx

    Edit to provide example

    ALTER TABLE [YourTable]
    ADD CONSTRAINT [YourConstraint] UNIQUE NONCLUSTERED ([name], [parent])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DB table that uses the following schema: CREATE TABLE users (id
Hi there I have an SQL table that looks like this: CREATE TABLE IF
I have a Linq-to-SQL model that uses stored procs in some places to return
I have a WCF that uses a ADO.NET Entity Data Model to access SQL
I have a database table that uses Sql Server 2005's uniqueidentifier column. I know
I have a table in Sql Server that contain an int field price that
I have a table in SQL that links to itself through parentID. I want
I have a table in SQL server that has the normal tree structure of
I have a History Table in SQL Server that basically tracks an item through
I have a table on SQL Server 2005 that was about 4gb in size.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.