Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9191139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:36:48+00:00 2026-06-17T20:36:48+00:00

project table proj_id, proj_name, Proj_Type 1, test, dev 2, test1, infra 3, test2, BI

  • 0

project table

proj_id, proj_name, Proj_Type
1, test, dev
2, test1, infra
3, test2, BI

quota table

quota_id, proj_id, allot_type, allot_num
1, 1, java, 3
2, 1, architect, 1
3, 1, Jasper, 2
4, 2, unix admin, 2
5, 2, dba, 1
6, 2, nwk admin, 1

tracking table

track_id, proj_id, status,start_date, sch_end_date,end_date, update_date
1,1, started,dec 16 2012,feb 12 2013,,01 jan 2013
2,2, resource allocated, 01 jan 2013, 03 mar 2013, , 01 jan 2013
3,3, yet to start, 19 jan 2013, 19 apr 2013

Destination table (Summary_Table)

event_id, proj_id, proj_name, Proj_Type, allot_type, allow_num, proj_start_date_sch_end_date, proj_status
1, 1, test,dev,java,3,16 dec 2012,12 feb 2013,started
2, 1, test,dev,architect,1,16 dec 2012, 12 feb 2013, started
3, 1, test,dev,jasper, 2, 16 dec 2012, 12 feb 2013, started

I have to write a stored procedure to load the destination table with the information from all three source tables

and another procedure to update the records regularly in destination table when ever there is a change in source tables such as project status changed from started to delivered etc.

Can some one give me some sample procedures to achieve above please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:36:50+00:00Added an answer on June 17, 2026 at 8:36 pm

    Load destination table

    • The store procedure will run only once – i.e. just to populate destination table?
    • Or for each insert in any of the three sources table will have to insert in destination table too?

      Just for loading just use a stored procedure

      INSERT INTO desitination ([columns])
      SELECT [columns]
      FROM project
      JOIN quota ON …
      JOIN tracking ON …

    For your second procedure – update destination table if there are any changes in source table, i would suggest to use triggers on update i.e.

    • set trigger for update on source tables that will update destination table records
      (http://dev.mysql.com/doc/refman/5.0/en/triggers.html)

    If you have to fill destination table each time when insert occurred in one of the source tables than will have to set a trigger for insert and update.

    If the inserts/updates are not at the db level, like you have any application that is interacting with db, then setting a stored procedure to handle updates on destination table might work.

    If you will provide the tables schema and some dummy data i can create a sample code.

    CREATE TABLE `project` (
      `proj_id` int(11) NOT NULL AUTO_INCREMENT,
      `proj_name` varchar(30) NOT NULL,
      `Proj_Type` varchar(30) NOT NULL,
      PRIMARY KEY (`proj_id`)
    );
    
    CREATE TABLE `quota` (
      `quota_id` int(11) NOT NULL AUTO_INCREMENT,
      `proj_id` int(11) NOT NULL,
      `allot_type` varchar(30) NOT NULL,
      `allot_num` INT(11) NOT NULL,
      PRIMARY KEY (`quota_id`)
    );
    
    CREATE TABLE `tracking` (
      `track_id` int(11) NOT NULL AUTO_INCREMENT,
      `proj_id` int(11) NOT NULL,
      `status` varchar(30) NOT NULL,
      `start_date` DATE NULL,
      `sch_end_date` DATE NULL,
      `end_date` DATE NULL,
      `update_date` DATE NULL,
      PRIMARY KEY (`track_id`)
    );
    
    CREATE TABLE `Destination` (
      `event_id` int(11) NOT NULL AUTO_INCREMENT,
      `proj_id` int(11) NOT NULL,
      `proj_name` varchar(30) NOT NULL,
      `Proj_Type` VARCHAR(30) NOT NULL,
      `allot_type` varchar(30) NOT NULL,
      `allot_num` INT(11) NOT NULL,
      `proj_start_date_sch_end_date` DATE NULL,
      `status` varchar(30) NOT NULL,
      PRIMARY KEY (`event_id`)
    );
    
    
    INSERT INTO `project` (`proj_id`, `proj_name`, `Proj_Type`) VALUES
    (1, 'test', 'dev'),
    (2, 'test1', 'infra'),
    (3, 'test2', 'BI');
    
    INSERT INTO `quota` (`quota_id`, `proj_id`, `allot_type`, `allot_num`) VALUES
    (1, 1, 'java', 3),
    (2, 1, 'architect', 1),
    (3, 1, 'Jasper', 2),
    (4, 2, 'unix admin', 2),
    (5, 2, 'dba', 1),
    (6, 2, 'nwk admin', 1);
    
    INSERT INTO `tracking`(`track_id`, `proj_id`, `status`, `start_date`, `sch_end_date`, `end_date`, `update_date`) VALUES 
    (1, 1, 'started', '2012-12-16', '2013-02-12', NULL, '2013-01-01'),
    (2, 2, 'resource allocated', '2013-01-01', '2013-03-03', NULL, '2013-01-01'),
    (3, 3, 'yet to start', '2013-01-19', '2013-04-19', NULL, NULL);
    
    
    delimiter $
    CREATE TRIGGER `uProjectChange` AFTER UPDATE ON project
    FOR EACH ROW BEGIN
    
        UPDATE `test`.`Destination` AS d 
      INNER JOIN `test`.`project` AS p ON p.proj_id = d.proj_id 
      SET 
        d.proj_name = p.proj_name,
        d.Proj_Type = p.Proj_Type;
    
    END;$
    delimiter ;
    
    
    -- Load destination table
    INSERT INTO `Destination` (`proj_id`, `proj_name`, `Proj_Type`, `allot_type`, `allot_num`, `proj_start_date_sch_end_date`, `status`) 
    SELECT 
        p.proj_id, p.proj_name, p.Proj_Type, 
        q.allot_type, q.allot_num,
        t.start_date, t.status
    FROM 
        project p 
    INNER JOIN quota q ON q.proj_id = p.proj_id 
    INNER JOIN tracking t ON t.proj_id = q.proj_id;
    
    -- UPDATE project SET  proj_name = 'test_test', Proj_Type = 'dev_test' WHERE proj_id = 1;
    -- UPDATE project SET  proj_name = 'test', Proj_Type = 'dev' WHERE proj_id = 1;
    SELECT * FROM `project`;
    SELECT * FROM `Destination`;
    

    http://sqlfiddle.com/#!8/43c77/1

    Here is the sample code – but i do have a question – why using destination table i.e. have a table, why you are not using a view instead?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project table with projectId as primary key: **projectId**, projectName, dateCreated, etc.
i have a project table which has a image_id field and a newsimage_id field.
I Have a DataBase in my project With Table named 'ProcessData' and columns named
In my project I have one table with 24*6*300 cells on one page (it's
We have a project where data is written to a logging table. Now, when
I have a mvc project and on one page there is a table of
I am making a project on a restaurant where I have put table reservation.
I have the following view and table in my project, vw_get_arabia_upod_full_details arabia_upod_item_avalability_master I want
I am trying to animate table rows in a UITableView in an iPhone project
I have a client table (with fields id, name) and a project table (with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.