Product to Catalog

  • I really thought I would find a vsd or a diagram that has the following elements on the interweb

    Product (product table)

    Catalog (Catalog associated to Vendors)

    Page of the catalog referring to the product (Pages Associated to the product)

    page PDF (image for the app)

    Then additional information (ie design values) that was associated to the product/page

    I looked in adventure works and there was nothing. I have a simple model in my head but was hoping to find something better that would make me think big picture. If you know of anything I would appreciate the help.

    attached is some code for a general idea.

    IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Sections]') AND type in (N'U'))

    CREATE TABLE [dbo].[Sections](

    [SectionsId] [uniqueidentifier] NOT NULL,

    [SectionTitle] [nvarchar](50) NOT NULL,

    [CatalogId] [uniqueidentifier] NOT NULL,

    CONSTRAINT [PK_Sections] PRIMARY KEY CLUSTERED

    (

    [SectionsId] ASC

    )) ON [PRIMARY]

    GO

    IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Catalog]') AND type in (N'U'))

    CREATE TABLE [dbo].[Catalog](

    [CatalogId] [uniqueidentifier] NOT NULL,

    [CatalogName] [nvarchar](50) NULL,

    [ManufacturersID] [uniqueidentifier] NOT NULL,

    CONSTRAINT [PK_Catalog] PRIMARY KEY CLUSTERED

    (

    [CatalogId] ASC

    )) ON [PRIMARY]

    GO

    IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CatalogPages]') AND type in (N'U'))

    CREATE TABLE [dbo].[CatalogPages](

    [PagesId] [int] NOT NULL,

    CONSTRAINT [PK_CatalogPages] PRIMARY KEY CLUSTERED

    (

    [PagesId] ASC

    )) ON [PRIMARY]

    GO

    /****** Object: Table [dbo].[Materials] Script Date: 11/07/2011 16:46:47 ******/

    IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Materials]') AND type in (N'U'))

    CREATE TABLE [dbo].[Materials](

    [MaterialsId] [uniqueidentifier] NOT NULL,

    [MaterialName] [nvarchar](50) NOT NULL,

    CONSTRAINT [PK_Materials_1] PRIMARY KEY CLUSTERED

    (

    [MaterialsId] ASC

    )) ON [PRIMARY]

    GO

    IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ProductPages]') AND type in (N'U'))

    CREATE TABLE [dbo].[ProductPages](

    [PagesId] [int] NOT NULL,

    [MaterialsId] [uniqueidentifier] NOT NULL,

    [SectionsId] [uniqueidentifier] NOT NULL,

    CONSTRAINT [PK_ProductPages] PRIMARY KEY CLUSTERED

    (

    [PagesId] ASC,

    [MaterialsId] ASC,

    [SectionsId] ASC

    )) ON [PRIMARY]

    GO

    IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductPages_CatalogPages]') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductPages]'))

    ALTER TABLE [dbo].[ProductPages] WITH CHECK ADD CONSTRAINT [FK_ProductPages_CatalogPages] FOREIGN KEY([PagesId])

    REFERENCES [dbo].[CatalogPages] ([PagesId])

    GO

    IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductPages_Materials]') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductPages]'))

    ALTER TABLE [dbo].[ProductPages] WITH CHECK ADD CONSTRAINT [FK_ProductPages_Materials] FOREIGN KEY([MaterialsId])

    REFERENCES [dbo].[Materials] ([MaterialsId])

    GO

    IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductPages_Sections]') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductPages]'))

    ALTER TABLE [dbo].[ProductPages] WITH CHECK ADD CONSTRAINT [FK_ProductPages_Sections] FOREIGN KEY([SectionsId])

    REFERENCES [dbo].[Sections] ([SectionsId])

    GO

    IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Sections_Catalog]') AND parent_object_id = OBJECT_ID(N'[dbo].[Sections]'))

    ALTER TABLE [dbo].[Sections] WITH CHECK ADD CONSTRAINT [FK_Sections_Catalog] FOREIGN KEY([CatalogId])

    REFERENCES [dbo].[Catalog] ([CatalogId])

    GO

  • I assume you are trying to figure out your data structures for this type of thing? Why not take a stab at it yourself and then post your table create scripts. You will get lots of very helpful hints from all the people around here. There just isn't a best practice or typical format for this sort of thing. There are certainly a lot of common elements but many of them will be very specific to your implementation.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply