help about create table relation

  • Hi!

    i want to consult about relations between tables.

    my database is interested with e-commerce. this is a sticker database.(i do a website and its owner sell stickers). i have product table.

    id PK

    pcode

    pname

    pimage

    pinformation

    A sticker has different sizes. for example a sticker can be 25cm*25cm or 80*50 size. So i made a table for this that is related with product table.

    id

    pid product id for products

    sizes

    price

    i think this model is true. Also i want to develop a table for campaign. For example if i give a product campaign, its price is shown reduced. i'm confused at this point.

    CAn anyone give an idea about tihs?

    Thanks...

  • You have the fundamental design here for sizes. They are related to the product, but there are many of them, so they are a child attribute.

    In terms of a campaign, you would typically relate this as well, so some

    create table campaign

    ( campaignid int

    , campaignname varchar(200)

    )

    go

    However the issue I see is that you might potentially have multiple products in a campaign, so I would likely like another child table:

    Create table productcampaign

    ( campaignid int

    , productid int

    , price numeric (10, 2)

    )

    The price in ProductCampaign could or could not be given. It could be an override that the application uses. A query could return both prices and the app could decide, or it could use a CASE to return one or the other.

  • Thanks..

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

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