Rating:
**Task:** One of De Monne's database engineers is having issues rebuilding the production database. He wants to know the name of one of the foreign keys on the loans database table. Submit one foreign key name as the flag: flag{foreign-key-name} (can be ANY foreign key).
In the previous challenge, I got around installing a software to manage DB on my computer and I've just used a text editor.
As I am preceding in the sql challenges, it is time to install software to be able to make sql requests.
First, I installed sqlite but I wasn't able to import the database. So, I've decided to launch a MySQL DB and phpMyAdmin using docker-compose.
```yaml
version: '3'
services:
db:
image: mysql:latest
container_name: db
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: app_db
MYSQL_USER: user
MYSQL_PASSWORD: password
ports:
- "6033:3306"
volumes:
- dbdata:/var/lib/mysql
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: pma
links:
- db
environment:
PMA_HOST: db
PMA_PORT: 3306
PMA_ARBITRARY: 1
restart: always
ports:
- 8081:80
volumes:
dbdata:
```
Then, I used phpMyAdmin [http://localhost:8081/](http://localhost:8081/) in my browser to manage the DB.
By default, we cannot import more than 2 Mb sql files using phpMyAdmin. A simple get around is to zip the sql file.
Then in order to found foreign keys on the loans table, I checked the structure page of that table on phpMyAdmin. (You can also use a text editor to check that.)
`fk_loans_loan_type_id`, `fk_loans_employee_id` and `fk_loans_cust_id` are all valid solutions.
![foreign keys](https://raw.githubusercontent.com/hhassen/writeup_deadface_2021/main/images/loan_fk.png)