What are primary and foreign keys? Explain the joins in SQL.
Asked in the Technical interview 1 stage. Write a PostgreSQL query that demonstrates these relationships by summarizing account activity for every customer.
customer_id, customer_name, account_count, and total_transaction_amount.customer_id ascending.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer's full name |
| Column | Type | Description |
|---|---|---|
| account_idPK | INT | Unique account identifier |
| customer_id | INT | Customer who owns the account |
| account_type | VARCHAR(30) | Type of account |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| account_id | INT | Account associated with the transaction |
| amount | DECIMAL(12,2) | Transaction amount |