Creating a simple database: is my approach OK?

This is a discussion on Creating a simple database: is my approach OK? within the C++ Programming forums, part of the General Programming Boards category; I'm trying to create a database of 8 movies with things about them (length,actor,actress,etc.) and output those things in a ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    33

    Creating a simple database: is my approach OK?

    I'm trying to create a database of 8 movies with things about them (length,actor,actress,etc.) and output those things in a table.

    At the point which I'm at in the code below, do I just need to declare the movies as the structure type and then assign them each a name of a movie? and do this for every aspect of the movie (length etc.)?

    Code:
    In the code below, would it be better to contruct hierarchical structure (record), including moviedescription,actors,actresses,etc. in their own struct? or keep it the way it is?
    
    The ultimate goal is to construct a small database of 8 movies via a C++ program that declares s struct type named videocollection, which will be a very simple database of information on popular movies (I think this tells me the answer right here, however, I just began reading about structs an hour ago so I'm just concerned I might have missed some critical things about organizing them). I got to put those things( actors,length,etc.) about each 8 movies in a table.
    
    
    Code:
    #include<iostream>
    
    using namespace std;
    
    int main()
    {
        struct Videocollection
    	{
    		string moviedescription;
    		string actor;
    		string actress;
    		int yearreleased;
    		int lengthofvideo;
    		string blackandwhiteorcolor;
    
    	};
    
    
    
    
    
    
    	return 0;
    
    }

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Make the struct global and create a vector or an array of the different movies.
    Code:
    struct Movie
    	{
    		string moviedescription;
    		string actor;
    		string actress;
    		int yearreleased;
    		int lengthofvideo;
    		string blackandwhiteorcolor;
    	};
    //Array
    Movie myCollection[8];
    //Vector
    vector<Movie> myDynamicCollection;
    But this will probably yield the best result.
    Code:
    //Start database
    system("rundll32 url.dll,FileProtocolHandler http://www.imdb.com");
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating very simple text editor using c
    By if13121 in forum C Programming
    Replies: 9
    Last Post: 10-19-2010, 05:26 PM
  2. Database assignment is Killing me!
    By Boltrig in forum C Programming
    Replies: 2
    Last Post: 11-29-2007, 02:56 AM
  3. Probably a simple question
    By Chles in forum C++ Programming
    Replies: 2
    Last Post: 08-05-2007, 02:41 AM
  4. Replies: 10
    Last Post: 05-18-2006, 11:23 PM
  5. Error connecting from Dev C++ to MS Access Database
    By Sridar in forum C++ Programming
    Replies: 0
    Last Post: 04-15-2006, 06:09 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21