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. Stored Procedures

Stored Procedures

Scheduled Pinned Locked Moved Database
questiondatabasedesignhelpannouncement
10 Posts 5 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.
  • M Offline
    M Offline
    Mahdi_kishislan
    wrote on last edited by
    #1

    Hi i want to design database that have different object but with the same structure . we have feeling table with this structure (code,name,id) also zone table with (code,name,id). my question is ,i have to design separate procedure for insert & update & delete or i can use one procedure for both table ?? is it possible to send table name?? is it good way to send table name from DAL OR BLL layer? please help me

    D C A 3 Replies Last reply
    0
    • M Mahdi_kishislan

      Hi i want to design database that have different object but with the same structure . we have feeling table with this structure (code,name,id) also zone table with (code,name,id). my question is ,i have to design separate procedure for insert & update & delete or i can use one procedure for both table ?? is it possible to send table name?? is it good way to send table name from DAL OR BLL layer? please help me

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      Keep it simple. Create 2 stored procedures. Just my opinion. :java:

      M 1 Reply Last reply
      0
      • D David Mujica

        Keep it simple. Create 2 stored procedures. Just my opinion. :java:

        M Offline
        M Offline
        Mahdi_kishislan
        wrote on last edited by
        #3

        tnx david.but i have 8 table with this structure .we have to design (delete,update,insert,SearchByName,SearchCode,....)store procedure .now what is the best way??

        D L 2 Replies Last reply
        0
        • M Mahdi_kishislan

          Hi i want to design database that have different object but with the same structure . we have feeling table with this structure (code,name,id) also zone table with (code,name,id). my question is ,i have to design separate procedure for insert & update & delete or i can use one procedure for both table ?? is it possible to send table name?? is it good way to send table name from DAL OR BLL layer? please help me

          C Offline
          C Offline
          Corporal Agarn
          wrote on last edited by
          #4

          You can use dynamic SQL but I would not suggest that. Create the stored procedures. It is easy to use cut and past for creating all you need, and if one table changes you only change on procedure. Another way would be to pass the table name into the procedure and have an IF ELSE IF structure within the procedure to update the tables.

          1 Reply Last reply
          0
          • M Mahdi_kishislan

            tnx david.but i have 8 table with this structure .we have to design (delete,update,insert,SearchByName,SearchCode,....)store procedure .now what is the best way??

            D Offline
            D Offline
            David Mujica
            wrote on last edited by
            #5

            Since the data structure of the table seems to be identical across these 8 tables, why don't you create a "super table" which contains the name of the table, followed by the other columns ? Data would look like: Feeling,code,name,id Zone,Code,name,id Table6,Code,name,id This way you would only implement a single set of Select,Insert,Upadate,Delete, just passing the name of the table as part of the "Where" clause. Kind of hard to describe, but hopefully you get the idea. :cool: Good luck. :thumbsup:

            M 2 Replies Last reply
            0
            • M Mahdi_kishislan

              tnx david.but i have 8 table with this structure .we have to design (delete,update,insert,SearchByName,SearchCode,....)store procedure .now what is the best way??

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Mahdi_kishislan wrote:

              now what is the best way??

              The best way would be a design where each table has a specific structure optimized for the data it is holding. By using a dump-table where all has the same structure, you'll loose a lot of advantages that a usual database offers - simple things like references and type-safety.

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

              D 1 Reply Last reply
              0
              • L Lost User

                Mahdi_kishislan wrote:

                now what is the best way??

                The best way would be a design where each table has a specific structure optimized for the data it is holding. By using a dump-table where all has the same structure, you'll loose a lot of advantages that a usual database offers - simple things like references and type-safety.

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                D Offline
                D Offline
                David Mujica
                wrote on last edited by
                #7

                I totally agree. It seems that his design is kind of lacking. I just tried answering his question. Sounds more like a homework assignment than a real project.

                1 Reply Last reply
                0
                • D David Mujica

                  Since the data structure of the table seems to be identical across these 8 tables, why don't you create a "super table" which contains the name of the table, followed by the other columns ? Data would look like: Feeling,code,name,id Zone,Code,name,id Table6,Code,name,id This way you would only implement a single set of Select,Insert,Upadate,Delete, just passing the name of the table as part of the "Where" clause. Kind of hard to describe, but hopefully you get the idea. :cool: Good luck. :thumbsup:

                  M Offline
                  M Offline
                  Mahdi_kishislan
                  wrote on last edited by
                  #8

                  tnx

                  1 Reply Last reply
                  0
                  • D David Mujica

                    Since the data structure of the table seems to be identical across these 8 tables, why don't you create a "super table" which contains the name of the table, followed by the other columns ? Data would look like: Feeling,code,name,id Zone,Code,name,id Table6,Code,name,id This way you would only implement a single set of Select,Insert,Upadate,Delete, just passing the name of the table as part of the "Where" clause. Kind of hard to describe, but hopefully you get the idea. :cool: Good luck. :thumbsup:

                    M Offline
                    M Offline
                    Mahdi_kishislan
                    wrote on last edited by
                    #9

                    tnx david

                    1 Reply Last reply
                    0
                    • M Mahdi_kishislan

                      Hi i want to design database that have different object but with the same structure . we have feeling table with this structure (code,name,id) also zone table with (code,name,id). my question is ,i have to design separate procedure for insert & update & delete or i can use one procedure for both table ?? is it possible to send table name?? is it good way to send table name from DAL OR BLL layer? please help me

                      A Offline
                      A Offline
                      Anudeep Jaiswal MCA
                      wrote on last edited by
                      #10

                      I Think You Should Add One More Column To Your Main Table As Type Now Your Table Structure Is (Code,Name,ID,Type) Now In Type Column You Can Insert Feeling Or Zone. And Now One One Insert Update And Delete Procedure Can Do The Same, As You Required. ------------------------------------------------------------------- Another Approach You Should Pass Table Name To Your Procedure And Create Dynamic Query. To Execute That Dynamic Query Use SP_ExecuteSQL Hope This Will Help You.......

                      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