Mysql Help

DooA

Well-known member
  • Jun 22, 2011
    5,202
    773
    113
    ආගිය අතක් නැත
    ප්‍රශ්නයක් තියෙනවා. මම පොඩි මෙව්වා එකක් හදනවා. එකේ තියෙනවා Order කියලා table එකක් තියෙනවා. එතකොට ඒ order එක යවන්නේ supplier කෙනෙක්ට. එතකොට මේකේ Main_suppliers and Sub_suppliers කියලා table දෙකක් තියෙනවා. Order කියන table එකේ supplier කියලා foreign key එකක් තියෙනවා.


    දැන් තමි හොදම අවුල. මේ column එකට relationship එක තියාගන විදියක් නැ. ඇයි ඉතින් මේකට එක්කෝ main supplier කෙනෙක් එන්න පුළුවන් නැත්නම් sub supplier කෙනෙක් එන්න පුළුවන්. ඒ table දෙකේම PK AI.

    මට කියන්නකෝ මේක හරි විදියට කරන්න කොහොමද ?



    මට කලින් වැරදුන. main and sub suppliers එක table එකක තියාගත්තා නම් ඔය අවුල එන්නේ na. Status කියල column එකක් දාලා තියන්න තිබ්බ . දැන් ඒ වැඩේ කරන්න බැ. මොකද ඒ part එක දැන් use කරනවා.
     

    D#rox

    Well-known member
  • Oct 6, 2013
    1,926
    211
    63
    රෙද්ද අස්සෙ
    Supplies hari eh mokak hari table eke supplierge name ekata eka column ekak dipan machan. eh karala name colum ekata passe thawa column ekak daapan supplier type eka. ekata ita passe check constraint ekak dipan....
    (supplier_type in(Main,Sub))
    ...kiyala. ethakota hari yai kiyala hithanawa :yes::yes:
     

    Radioactive

    Member
    Jul 22, 2014
    10,047
    732
    0
    Main Suppliers, Sub Suppliers කිව්වම, දෙකම Suppliers ලනේ. එතකොට එක table එකක දාන්න.
    Suppliers කියන entity එකට දෙකම අයිතියි, ඊට පස්සේ table එක normalize කරන්න. මට fields ටික දෙන්න, මම normalize කරලා, relationships හදලා දෙන්නක් එතකොට.
     
    • Like
    Reactions: DooA

    DooA

    Well-known member
  • Jun 22, 2011
    5,202
    773
    113
    ආගිය අතක් නැත
    Supplies hari eh mokak hari table eke supplierge name ekata eka column ekak dipan machan. eh karala name colum ekata passe thawa column ekak daapan supplier type eka. ekata ita passe check constraint ekak dipan....
    (supplier_type in(Main,Sub))
    ...kiyala. ethakota hari yai kiyala hithanawa :yes::yes:

    ඕක තමයි මටත් හිතුනේ
     

    DooA

    Well-known member
  • Jun 22, 2011
    5,202
    773
    113
    ආගිය අතක් නැත
    Main Suppliers, Sub Suppliers කිව්වම, දෙකම Suppliers ලනේ. එතකොට එක table එකක දාන්න.
    Suppliers කියන entity එකට දෙකම අයිතියි, ඊට පස්සේ table එක normalize කරන්න. මට fields ටික දෙන්න, මම normalize කරලා, relationships හදලා දෙන්නක් එතකොට.

    දැන් එක වෙනස් කරන්න බැ බන්. මොකද දැන් software ඒ පාර්ට් එක use කරනවා
     

    Radioactive

    Member
    Jul 22, 2014
    10,047
    732
    0
    ඒක තමයි බන් ,Software හදන්න කලින් Design කරන්න ඕනේ කියන්නේ හරියට. හොද Architect (software designer ට කියන්නේ මේ නමයි) කෙනෙක් නැතුව Software හදන්න නරකයි නැත්නම් update කරන කොට පන යනවා. මම මේ ළගදි software එකක් හැදුවා, MsSQL වලින් ඒකට මම දවස් දෙකක් වැය කරා design කරන්නම.
     

    DooA

    Well-known member
  • Jun 22, 2011
    5,202
    773
    113
    ආගිය අතක් නැත
    ඒක තමයි බන් ,Software හදන්න කලින් Design කරන්න ඕනේ කියන්නේ හරියට. හොද Architect (software designer ට කියන්නේ මේ නමයි) කෙනෙක් නැතුව Software හදන්න නරකයි නැත්නම් update කරන කොට පන යනවා. මම මේ ළගදි software එකක් හැදුවා, MsSQL වලින් ඒකට මම දවස් දෙකක් වැය කරා design කරන්නම.

    මගේ ගොන් කම බන්. part part හදන nisa part part design කරා. දැන් ඉකවිලා. අයෙ එහෙම නොකරමි. දැන් ඉතින් update karanawa.
     

    Lihrox

    Well-known member
  • Jul 11, 2009
    989
    56
    48
    Order table eke foreign key column 2k thiyaganin ban Main_supplier table ekata ekai sub_supplier ekata ekai

    let's say,

    Order(
    order_id int PRIMARY KEY,
    Main_suppier string //foreign key from Main_supplier
    Sub_suppier string //foreign key from Sub_supplier
    )


    if order is from a main supplier, Sub_suppier value will be null
    if order is from a sub supplier, Main_suppier value will be null

    Hope this will help
    :yes::yes:
     
    • Like
    Reactions: DooA

    DooA

    Well-known member
  • Jun 22, 2011
    5,202
    773
    113
    ආගිය අතක් නැත
    Order table eke foreign key column 2k thiyaganin ban Main_supplier table ekata ekai sub_supplier ekata ekai

    let's say,

    Order(
    order_id int PRIMARY KEY,
    Main_suppier string //foreign key from Main_supplier
    Sub_suppier string //foreign key from Sub_supplier
    )


    if order is from a main supplier, Sub_suppier value will be null
    if order is from a sub supplier, Main_suppier value will be null

    Hope this will help
    :yes::yes:


    eh widiha try ekak dala balapan machan. mokada normalyse walata wenama table ekkak gahanawata wada oka lesi kiyalai mama hithanne :yes::yes:

    elakiri machn ohoma thamai karanne
     
    • Like
    Reactions: D#rox

    itsnotme

    Member
    Sep 25, 2010
    622
    34
    0
    එතකොට, main category , sub catehory :oo::oo::oo::oo::oo:

    ඒක වෙන කතන්දරයක් නේ මචන්.

    main category එකේ උප කුලක නේ sub category කියන්නේ. එතකොට category එක subCategory කියල තව table එකකට normalize වෙන්න ඕන. අරකෙදි එහෙම නැ. supplier, sub supplier කියන්නේ වෙන වෙනම දෙකක් නේ.
     
    Last edited:

    hspa3.5

    Well-known member
  • Sep 23, 2009
    4,539
    543
    113
    my world
    Order table eke foreign key column 2k thiyaganin ban Main_supplier table ekata ekai sub_supplier ekata ekai

    let's say,

    Order(
    order_id int PRIMARY KEY,
    Main_suppier string //foreign key from Main_supplier
    Sub_suppier string //foreign key from Sub_supplier
    )


    if order is from a main supplier, Sub_suppier value will be null
    if order is from a sub supplier, Main_suppier value will be null

    Hope this will help
    :yes::yes:

    oka kaloth ubata report hadaddi amaru wei wage kollo...