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

  • SEARCH
  • Home
  • 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 6905475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:11:16+00:00 2026-05-27T08:11:16+00:00

I would like to design a table named arguments whose an attribute name is

  • 0

I would like to design a table named arguments whose an attribute name is linked to another attribute name in a table called names.

I see two ways to express it in SQL:

  1. by creating a constraint on the table:

    CREATE TABLE names (   name text UNIQUE,
                          short text UNIQUE,
                        comment text);
    CREATE TABLE arguments (   name text UNIQUE,
                            comment text,
                            FOREIGN KEY (name) REFERENCES names (name));
    
  2. by qualifying the attribute on-the-fly:

    CREATE TABLE names (   name text UNIQUE,
                          short text UNIQUE,
                        comment text);
    CREATE TABLE arguments (   name text UNIQUE REFERENCES names (name),
                            comment text);
    

I would like to know:

  • if one of the two is commonly known as better than the other, and
  • if it can have consequences that I should be aware of.

Thank you for your help.

  • 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-27T08:11:16+00:00Added an answer on May 27, 2026 at 8:11 am

    While the first option is known as out-of-line constraint declaration and the second option is in-line, both of them are functionally same.

    What would be better is to assign a name to the foreign key constraint. If you have a name, you can selectively enable and disable the constraint if required.

    Create table

    CREATE TABLE arguments 
    (   
        name text UNIQUE,                         
        comment text,                         
        constraint arguments_fk FOREIGN KEY (name) REFERENCES names (name)
    ); 
    

    Disable constraint

    ALTER TABLE arguments NOCHECK CONSTRAINT arguments_fk;
    

    Enable constraint

    ALTER TABLE arguments CHECK CONSTRAINT arguments_fk;
    

    This is for SQL Server. Oracle has equivalent commands.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My design exposes two kinds of resources: Images Tags I would like clients to
I would like to ask about the design of table based on it's editability
I would like to create a table called NOTES. I was thinking this table
I would like to design very high availability(never take server down, roll out features
I'm looking into a restful design and would like to use the HTTP methods
I have an UserControl and would like to hide the resizing handles in design-time,
I am running into a design disagreement with a co-worker and would like people's
We are in the process of nutting out the design guidelines we would like
I have this design which I cannot seem to get right, I would like
I have an OS design project with some subprojects, I would like to try

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.