This project involves creating a database named universe
using PostgreSQL
. The database will consist of several tables, each representing a different celestial body. Here are the detailed instructions:
- Create a database named
universe
. - Connect to your database with
\c universe
. - Add tables named
galaxy
,star
,planet
, andmoon
.- Each table should have a
primary key
that automatically increments. - Each table should have a
name
column of typeVARCHAR
. - At least two columns per table should not accept
NULL
values. - At least one column from each table should be required to be
UNIQUE
. - Each
primary key
column should follow the naming conventiontable_name_id
. For example : themoon
table should have aprimary key
column namedmoon_id
.
- Each table should have a
- Use the
INT
data type for at least two columns that are not a primary or foreign key. - Use the
NUMERIC
data type at least once. - Use the
TEXT
data type at least once. - Use the
BOOLEAN
data type on at least two columns. - Each
star
should have aforeign key
that references one of the rows ingalaxy
. - Each
planet
should have aforeign key
that references one of the rows instar
. - Each
moon
should have aforeign key
that references one of the rows inplanet
.- Each
foreign key
column should have the same name as thecolumn
it is referencing.
- Each
- Your database should have at least five
tables
. - Each table should have at least three rows.
- The
galaxy
andstar
tables should each have at least six rows. - The
planet
table should have at least 12 rows. - The
moon
table should have at least 20 rows.
- The
- Each table should have at least three columns.
- The
galaxy
,star
,planet
, andmoon
tables should each have at least five columns.
- The
- Compact all queries into a
universe.sql
file.
Remember, the goal of this project is to practice creating and manipulating databases using PostgreSQL
. Make sure to test your database thoroughly to ensure it meets all the requirements.