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

  • SEARCH
  • Home
  • 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 652907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:19:26+00:00 2026-05-13T22:19:26+00:00

i have created a db names movielibrarysystem in which i have 3 tables.. that

  • 0

i have created a db names movielibrarysystem in which i have 3 tables..

that are type,publisher and movie… now 1 publisher could have many many movies and 1 movie is of many type.. in the movie table, the publisher id as well as the typeid are acting as a foreign keys..

my question is that how to insert a data into a movie table… i have already inserted data into publisher and type tables but i`m not able to insert into movie table..

  • 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-05-13T22:19:27+00:00Added an answer on May 13, 2026 at 10:19 pm

    Here’s what you do. First, the relationship between publisher and movie is one to many – a publisher can publish many movies but each movie only has one publisher. However, type to movie is a many-to-many relationship (you state that one movie is of many types, but it’s also the case that one type is of many movies), so you should have an extra table for that relationship.

    Essentially:

    publisher:
        publisher_id
        publisher_name
        <other publisher info>
    type:
        type_id
        type_name
        <other type info>
    movie:
        movie_id
        movie_name
        publisher_id references publisher(publisher_id)
        <other movie info>
    movie_type:
        movie_id references movie(movie_id)
        type_id references type(type_id)
    

    with suitable primary keys for all those.

    Then assuming you have the publisher and type inserted, you can insert the movie thus:

    begin transaction;
    insert into movie (movie_name,publisher_id) values (
        'Avatar',
        (select publisher_id from publisher where publisher_name = 'Spielberg')
    );
    insert into movie_type (movie_id,type_id) values (
        (select movie_id from movie where movie_name = 'Avatar'),
        (select type_id from type where type_name = 'SciFi')
    );
    insert into movie_type (movie_id,type_id) values (
        (select movie_id from movie where movie_name = 'Avatar'),
        (select type_id from type where type_name = 'GrownUpSmurfs')
    );
    commit;
    

    In other words, you use sub-selects to get the IDs from the relevant tables based on a unique set of properties (above example assumes movie names are unique, in reality you will need a more specific query, such as to handle the different films with the same name: The Omega Man, for example).

    If you’re not using a DBMS that supports selects in value sections, your best bet will be probably just to remember or extract the relevant values to a variable in whatever programming language you’re using and construct a query to do it. In pseudo-code:

    begin transaction;
    insert into movie (movie_name,publisher_id) values (
        'Avatar',
        (select publisher_id from publisher where publisher_name = 'Spielberg')
    );
    select movie_id into :m_id from movie where movie_name = 'Avatar';
    select type_id into :t_id1 from type where type_name = 'SciFi';
    select type_id into :t_id2 from type where type_name = 'GrownUpSmurfs';
    insert into movie_type (movie_id,type_id) values (:m_id, :t_id1);
    insert into movie_type (movie_id,type_id) values (:m_id, :t_id2);
    commit;
    

    In response to your comment:

    hey, i didn’t got the point that of type and movie relationship.. will you please elaborate this point .. regards Abid

    Both Avatar and Solaris can be considered of the type SciFi. So many movies to one genre. And Xmen:Wolverine can be considered both action and comic-remake. So many types to one movie.

    Many-to-many relationships are best represented with a separate table containing the cross matches between the two related tables.

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

Sidebar

Related Questions

I have created a table in sql server which holds names of tables in
I have created a bunch of movie clips which all have similar names and
I have created a list view that displays the names and dates of items
I have created a custom shipping method to show depo-names from which customers will
I have a table containing a series of names, events and dates. I've created
I have created a application which will list the names . Whenever the name
I have created a function which displays a bus seat layout, dynamically. Now after
I have created a few php files Following are their names: standard_head.php (which contains
I have created a data-structure in Mysql with table name(CSV filename) and field names(CSV
I have created a MYSQL stored procedure that searches all columns of a table

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.