Currently I have two postgres 9 databases for two different datasources.
Database 1 is called musicbrainz, the main user is musicbrainz and tables are created in schema musicbrainz
Database 2 is called discogs, the main user is discogs and tables are created in schema discogs
I now need to do queries that involves tables from both databases, so I want to put all the tables in one single database. I'm happy to start again and load the data from the original data files but whats the easiest way to do this, specifically I'm a little confused between the relationship between username, schemaname and databasename and having a schema named the same as the database/ or user rather than using public.
Additional problem there are some tables with the same name in both databases (musicbrainz and discogs) although renaming one sense would be a possibility. Note the database is only for user by a single user (me)
Solution I've decided to do it this way:
- Create new database musicdata
- Create new database superuser that matches unix username
- Create schema musicbrainz and discogs
- Set users schema search path to musicbrainz
- Import musicbrainz data into musicdata with schema musicbrainz
- Set user schema search path to discogs
- Import disocgs data into musicdata with schema discogs
- Set users schema search path to musicbrainz, discogs
- Check can see all tables with psql and \dt;
Working okay so far