Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Subqueries

Subqueries

Scheduled Pinned Locked Moved Database
questiondatabasesql-serversysadmin
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 11127370
    wrote on last edited by
    #1

    Hi, I want to know that while creating suqueries in SQL Server,it is mandatory to have Primary key and Foreign key relationships between the tables??? In short:-I want to know if we create subqueries without p.k and F.k realtionships,then it will work??? What is the main purpose of Subqueries??? Thanks...

    M 1 Reply Last reply
    0
    • U User 11127370

      Hi, I want to know that while creating suqueries in SQL Server,it is mandatory to have Primary key and Foreign key relationships between the tables??? In short:-I want to know if we create subqueries without p.k and F.k realtionships,then it will work??? What is the main purpose of Subqueries??? Thanks...

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      In Short: Yes The relationship structure is an integral part of the data structure but is not required for sub queries. Sub queries are just another tool for getting your data from the database the way you want it. Like CTEs and the various joins they are all aspects of TSQL.

      Never underestimate the power of human stupidity RAH

      Richard Andrew x64R 1 Reply Last reply
      0
      • M Mycroft Holmes

        In Short: Yes The relationship structure is an integral part of the data structure but is not required for sub queries. Sub queries are just another tool for getting your data from the database the way you want it. Like CTEs and the various joins they are all aspects of TSQL.

        Never underestimate the power of human stupidity RAH

        Richard Andrew x64R Offline
        Richard Andrew x64R Offline
        Richard Andrew x64
        wrote on last edited by
        #3

        I have often wondered this myself. Since I can perform a join simply by saying "WHERE a.field = b.field", what is the ultimate purpose of setting up a relationship?

        The difficult we do right away... ...the impossible takes slightly longer.

        W M 2 Replies Last reply
        0
        • Richard Andrew x64R Richard Andrew x64

          I have often wondered this myself. Since I can perform a join simply by saying "WHERE a.field = b.field", what is the ultimate purpose of setting up a relationship?

          The difficult we do right away... ...the impossible takes slightly longer.

          W Offline
          W Offline
          Wonde Tadesse
          wrote on last edited by
          #4

          Richard Andrew x64

          what is the ultimate purpose of setting up a relationship?

          Referential Integrity[^]

          Wonde Tadesse

          1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            I have often wondered this myself. Since I can perform a join simply by saying "WHERE a.field = b.field", what is the ultimate purpose of setting up a relationship?

            The difficult we do right away... ...the impossible takes slightly longer.

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            Wonde nailed it, IMHO referential integrity and constraints are the last line of defense to keep the garbage in. They also help with optimisation of course.

            Never underestimate the power of human stupidity RAH

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups