|
Posted by --CELKO-- on 03/16/07 14:40
>> I have set up a database for movies. <<
Actually, you don't; such things already exist and you can download
them.
>> In one table (Movies) I have movie names, and production years, and also genres. In another table (Directors), I keep the directors and the movies they directed. <<
If a movie can have more than one director, then where is the
relationship table?
>> Another table (People) keeps the names of the people. Everybody will have a unique ID. <<
It is nice to know you do not consider Directors to be people and put
them ina separate table :)
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. Sample data is also a good idea, along with clear
specifications. It is very hard to debug code when you do not let us
see it.
>> I have created a query like below to show the name and production year of the movie, the director name and the genre of the movie. <<
What you posted is completely wrong. The data element names are too
vague to be useful and involve reserved words. You are so far off
base, you even have the magical, universal id column which changes
meaning from table to table! Tell me that you did not use an IDENTITY
in all your tables for this.
CREATE TABLE Movies
(<<industry standard if>>,
release_year INTEGER NOT NULL,
genre_code CHAR(10) NOT NULL,
etc.);
CREATE TABLE Personnel (..) -- SAG number as id?
CREATE TABLE Crew (..) -- includes role played by personnel on a movie
Start over with a relational design or your teacher will give you a
really bad grade.
>
> SELECT Movies.Name, Movies.Year, People.Name AS Director, Genres.Genre
> FROM Movies INNER JOIN Directors ON Movies.ID = Directors.MovieID
> INNER JOIN Genres ON Movies.Genre = Genres.ID INNER JOIN People ON
> Directors.ID = People.ID WHERE (Movies.ID = @MoviesID)
>
> The problem is that it does not return any result. What might be the
> problem?
>
> Thanks in advance...
Navigation:
[Reply to this message]
|