I have another homework question for my Movie database for college, how do I add data into a table? I hope I asked that question correctly. My teacher wants to see 10 records next week for a grade. The tables are Genre, Movies, Actor, Movie Rating,and Directors. I have two junction tables which are Movie Actors and Movie Directors that she wants to see in data in. Thanks for the help.
Try to create the records in an excel. say in columns a1, b1, c1 and d1. The in another column say g1 write a concatenate excel formula something like =CONCATENATE("INSERT INTO TableName (Column1, column2, column3, column4) VALUES(",A1,",",B1,",",C1,",",D1,")") then drag this according to the number of rows of data you have to generate the data insert scripts for the table.For string values pls concatenate double quotes before and after the value. Note if you include dollar in cellnames like $A$1 then the cell will always point to a1 cell even if you drag them.Also be careful about identity columns when you are doing an insert. There are many methods to do an insert quickly, this is something I do frequently. Using an Import and export wizard makes life even more easier.All you need is to configure the input and output.You could try that option as well. Thanks, Kannan
First, let me concur with Grant that your best bet is to look up the word "Insert" in an appropriate reference. But let me just add that in SQL, as in most things in programming, there are many ways to achieve the same goal. Kannan has already mentioned one, you can also open the table in SSMS for a GUI (though there are so many issues with this technique that I only ever use it to put data into a very small test table), BCP, BULK INSERT, etc. In short, when you are ready to get to that point just be aware that there are a lot of places to look. But just start with "Insert" like Grant said.
I assume you know how to use the INSERT statement, but what you really want to know is how do I make sense of these junction tables? Generally it is easier to join these tables if you have a surrogate key column in the Genre, Movie and Actor tables. This can be implemented by adding a monotonically increasing number column with the IDENTITY keyword when creating the table eg CREATE TABLE Movie(MovieID int Identity, MovieName varchar(50)) Do the same with Genre and Actor. The join tables could then take the form CREATE TABLE MovieActor(MovieID int, ActorID int) So that a row in MovieActor such as (1,3) would link the 3rd Actor in your Actor table to the 1st Movie.