sabadvali sabadvali - 2 months ago 8
MySQL Question

Table row in sql as new table

I have a table with ID,Name,Date and Category.
I want Category to be also a table,with rows ID and Name.
how can I do this?

Answer

Hello This Is Kind OF a big Conceptual question You Should learn more about this .I am adding some ans for your question the table creation Query

   CREATE TABLE Info_table(
   ID   INT          NOT NULL,
   NAME VARCHAR (20) NOT NULL,
   Date  date        NOT NULL,
   Category_ID INT references CATEGORIES(ID),
   PRIMARY KEY (ID)
    );
    /*Category Table */
    CREATE TABLE Category_table(
   ID   INT              NOT NULL,
   Category_NAME VARCHAR (20) NOT NULL,    
   PRIMARY KEY (ID) /*Primary Key which is used as a foreign key in the first table  */
   );

I am also adding a sample picture related to this query see that hope It helps You RelationShip