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. General Programming
  3. C#
  4. Design Question: Correct way to show data from mutliple DB tables

Design Question: Correct way to show data from mutliple DB tables

Scheduled Pinned Locked Moved C#
databasequestioncsharpasp-netcom
3 Posts 2 Posters 1 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.
  • J Offline
    J Offline
    James Spibey
    wrote on last edited by
    #1

    Hey Guys, Here's the problem: I'm trying to learn multi-tier design so I've been writing a little app to teach myself. I have a normalised SQLServer database which contains my music collection. The DB schema is here[^]. So, I used LLBLGen[^] to generate a C# class for each of my table entities and that works great. There are SelectOne() and SelectAll() methods on each of my entities which allow you to select one record or the whole table. My question is: how do I join the tables together? And how do I search them? I tried asking on the asp.net forums but they just suggested buying a OR mapper tool. Cheers James

    M 1 Reply Last reply
    0
    • J James Spibey

      Hey Guys, Here's the problem: I'm trying to learn multi-tier design so I've been writing a little app to teach myself. I have a normalised SQLServer database which contains my music collection. The DB schema is here[^]. So, I used LLBLGen[^] to generate a C# class for each of my table entities and that works great. There are SelectOne() and SelectAll() methods on each of my entities which allow you to select one record or the whole table. My question is: how do I join the tables together? And how do I search them? I tried asking on the asp.net forums but they just suggested buying a OR mapper tool. Cheers James

      M Offline
      M Offline
      Michael Potter
      wrote on last edited by
      #2

      It will be kind of difficult using the schema you have defined. Where are your foreign keys (FKs)? The full join should look something like this (assuming proper FK development):

      SELECT *
      FROM Artists
      INNER JOIN Albums ON (Artists.ArtistId = Albums.ArtistId)
      INNER JOIN Tracks ON (Albums.AlbumId = Tracks.AlbumId)
      INNER JOIN Files ON (Tracks.TrackId = Files.TrackId)
      

      The type of joins you need to develop will depend on how you want the data displayed.

      J 1 Reply Last reply
      0
      • M Michael Potter

        It will be kind of difficult using the schema you have defined. Where are your foreign keys (FKs)? The full join should look something like this (assuming proper FK development):

        SELECT *
        FROM Artists
        INNER JOIN Albums ON (Artists.ArtistId = Albums.ArtistId)
        INNER JOIN Tracks ON (Albums.AlbumId = Tracks.AlbumId)
        INNER JOIN Files ON (Tracks.TrackId = Files.TrackId)
        

        The type of joins you need to develop will depend on how you want the data displayed.

        J Offline
        J Offline
        James Spibey
        wrote on last edited by
        #3

        Thanks for the reply Michael. I know how to do the JOIN in sql, that's not the problem. The problem is that from a design point of view each table is a separate C# class upon which I call the CRUD methods (album.Delete(), album.SelectOne() etc). What I need to know is what is the best way of joining the tables under this scenario? I've been think of defining views for each JOIN which I require and then generating classes for each of those but I'm not convinced it is the best way to go about it. Cheers James

        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