{"id":49779746,"url":"https://github.com/ctrl-alt-d/AccidentsAmbVictimes","last_synced_at":"2026-05-28T09:00:55.203Z","repository":{"id":323530754,"uuid":"1090958064","full_name":"ctrl-alt-d/AccidentsAmbVictimes","owner":"ctrl-alt-d","description":"Exercici de base de dades","archived":false,"fork":false,"pushed_at":"2025-11-16T11:07:14.000Z","size":49589,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-21T02:28:54.598Z","etag":null,"topics":["dam","database","daw","exercises","learning","prefill-database","sample"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ctrl-alt-d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-06T11:15:32.000Z","updated_at":"2025-11-29T20:55:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ctrl-alt-d/AccidentsAmbVictimes","commit_stats":null,"previous_names":["ctrl-alt-d/accidentsambvictimes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ctrl-alt-d/AccidentsAmbVictimes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrl-alt-d%2FAccidentsAmbVictimes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrl-alt-d%2FAccidentsAmbVictimes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrl-alt-d%2FAccidentsAmbVictimes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrl-alt-d%2FAccidentsAmbVictimes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctrl-alt-d","download_url":"https://codeload.github.com/ctrl-alt-d/AccidentsAmbVictimes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrl-alt-d%2FAccidentsAmbVictimes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33601380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dam","database","daw","exercises","learning","prefill-database","sample"],"created_at":"2026-05-11T19:00:25.521Z","updated_at":"2026-05-28T09:00:55.197Z","avatar_url":"https://github.com/ctrl-alt-d.png","language":"C#","funding_links":[],"categories":["List"],"sub_categories":[],"readme":"\n# Accidents Amb Víctimes\n\n## Descripció\n\n\u003cimg align=\"left\" src=\"./Kahoot/p-1.png\" alt=\"Gat accidentat. Imatge de decoració\" width=\"100\" style=\"margin-right: 15px;\"/\u003e\n\n[Cat] Dataset d'[accidents de trànsit amb víctimes a Catalunya](https://analisi.transparenciacatalunya.cat/Transport/Accidents-de-tr-nsit-amb-morts-o-ferits-greus-a-Ca/rmgc-ncpb/about_data) carregat a una base de dades (Postgres, MySql o MSSqlServer) amb objectius acadèmics. Permet treballar les consules sql (projecció, selecció, agregats, funcions amb dates, etc). Totes les dades són a una sola taula. Disponible [Kahoot](#kahoot).\n\n[Eng] Dataset of [traffic accidents with victims in Catalonia](https://analisi.transparenciacatalunya.cat/Transport/Accidents-de-tr-nsit-amb-morts-o-ferits-greus-a-Ca/rmgc-ncpb/about_data) loaded into a database (Postgres, MySQL or SQL Server) for academic purposes. Allows working with SQL queries (projection, selection, aggregates, date functions, etc). All data is in a single table. [Kahoot](#kahoot) available.\n\n\u003cbr clear=\"left\"/\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003ePot ser que hi hagi un dataset nou publicat a Dades Obertes?\u003c/summary\u003e\nLa darrera versió de les dades es pot descarregar des de:\n\n👉 [Accidents de trànsit amb morts o ferits greus a Catalunya (Dades Obertes)](https://analisi.transparenciacatalunya.cat/Transport/Accidents-de-tr-nsit-amb-morts-o-ferits-greus-a-Ca/rmgc-ncpb/about_data)\n\nDescarrega el fitxer CSV i col·loca'l a la carpeta `Data/` si vols actualitzar les dades.\n\n\u003c/details\u003e\n\n---\n\n## Com engegar l'entorn\n\nAquest projecte suporta **PostgreSQL**, **MySQL** i **SQL Server** (Azure SQL Edge). Pots seleccionar el gestor de base de dades que vulguis utilitzar mitjançant profiles de Docker Compose.\n\n### Prerequisits\n\n- **[Docker](https://www.docker.com/)** instal·lat i en funcionament\n\n### Engegar l'entorn amb la base de dades que vulguis\n\n```bash\n# PostgreSQL\ndocker compose --profile postgres up --build\n\n# MySQL\ndocker compose --profile mysql up --build\n\n# SQL Server (Azure SQL Edge)\ndocker compose --profile sqlserver up --build\n```\n\n### Aturar i netejar l'entorn\n\n```bash\n# Aturar contenidors\ndocker compose down\n\n# Eliminar contenidors i dades persistents\ndocker compose down -v\n```\n\n---\n\n## Connexió a la base de dades des de DBeaver\n\n### PostgreSQL\n\n- **Host:** `localhost`\n- **Port:** `5432`\n- **Usuari:** `postgres`\n- **Contrasenya:** `123456`\n- **Base de dades:** `victimes`\n\n### MySQL\n\n- **Host:** `localhost`\n- **Port:** `3306`\n- **Usuari:** `root`\n- **Contrasenya:** `123456`\n- **Base de dades:** `victimes`\n\n### SQL Server (Azure SQL Edge)\n\n- **Host:** `localhost`\n- **Port:** `1433`\n- **Usuari:** `sa`\n- **Contrasenya:** `Str0ngPass!`\n- **Base de dades:** `victimes`\n\nFes clic a \"Test Connection\" per comprovar que tot funciona. Ara pots explorar i consultar les dades importades!\n\n---\n\n## Diccionari de dades\n\nLa base de dades conté informació detallada sobre accidents de trànsit amb víctimes a Catalunya. A continuació es descriu cada camp:\n\n### Informació bàsica de l'accident\n\n| Camp | Descripció | Description | Tipus |\n|------|------------|-------------|-------|\n| `any` | Any de l'accident | Year of the accident | Nombre |\n| `dat` | Data de l'accident | Date of the accident | Data/hora |\n| `zona` | Tipus de zona on s'ha produït l'accident (Zona urbana, Carretera) | Type of zone where the accident occurred (Urban area, Road) | Text |\n| `via` | Tipus de via on s'ha produït l'accident | Type of road where the accident occurred | Text |\n| `pk` | Punt quilomètric on s'ha produït l'accident | Kilometer point where the accident occurred | Decimal (nullable) |\n\n### Ubicació\n\n| Camp | Descripció | Description | Tipus |\n|------|------------|-------------|-------|\n| `nommun` | Municipi on s'ha produït l'accident | Municipality where the accident occurred | Text |\n| `nomcom` | Comarca on s'ha produït l'accident | County where the accident occurred | Text |\n| `nomdem` | Demarcació on s'ha produït l'accident | Region where the accident occurred | Text |\n\n### Víctimes i vehicles implicats\n\n| Camp | Descripció | Description | Tipus |\n|------|------------|-------------|-------|\n| `f_morts` | Nombre de morts en l'accident | Number of deaths in the accident | Nombre |\n| `f_ferits_greus` | Nombre de ferits greus en l'accident | Number of seriously injured in the accident | Nombre |\n| `f_ferits_lleus` | Nombre de ferits lleus en l'accident | Number of minor injuries in the accident | Nombre |\n| `f_victimes` | Nombre total de víctimes en l'accident | Total number of victims in the accident | Nombre |\n| `f_unitats_implicades` | Nombre de vehicles implicats | Number of vehicles involved | Nombre |\n| `f_vianants_implicades` | Nombre de vianants implicats a l'accident | Number of pedestrians involved in the accident | Nombre |\n| `f_bicicletes_implicades` | Nombre de bicicletes implicades a l'accident | Number of bicycles involved in the accident | Nombre |\n| `f_ciclomotors_implicades` | Nombre de ciclomotors implicats a l'accident | Number of mopeds involved in the accident | Nombre |\n| `f_motocicletes_implicades` | Nombre de motocicletes implicades a l'accident | Number of motorcycles involved in the accident | Nombre |\n| `f_veh_lleugers_implicades` | Nombre de vehicles lleugers implicats a l'accident | Number of light vehicles involved in the accident | Nombre |\n| `f_veh_pesants_implicades` | Nombre de vehicles pesants implicats a l'accident | Number of heavy vehicles involved in the accident | Nombre |\n| `f_altres_unit_implicades` | Nombre d'altres tipus d'unitats implicades a l'accident | Number of other types of units involved in the accident | Nombre |\n| `f_unit_desc_implicades` | Nombre d'unitats de tipus desconegut implicades a l'accident | Number of units of unknown type involved in the accident | Nombre |\n\n### Característiques de la via i l'entorn\n\n| Camp | Descripció | Description | Tipus |\n|------|------------|-------------|-------|\n| `c_velocitat_via` | Velocitat permesa a la via | Speed limit on the road | Nombre (nullable) |\n| `d_caract_entorn` | Característiques del terreny | Terrain characteristics | Text |\n| `d_carril_especial` | Existència de carril especial | Existence of special lane | Text |\n| `d_circulacio_mesures_esp` | Mesures especials de circulació | Special traffic measures | Text |\n| `d_func_esp_via` | Via amb funció especial | Road with special function | Text |\n| `d_inter_seccio` | Accident produït en intersecció | Accident occurred at intersection | Text |\n| `d_limit_velocitat` | Visualització del límit de velocitat de la via | Visibility of the road's speed limit | Text |\n| `d_regulacio_prioritat` | Regulació de la prioritat a la via | Priority regulation on the road | Text |\n| `d_sentits_via` | Sentits de la via | Road directions | Text |\n| `d_subtipus_tram` | Classificació del tipus de tram | Classification of the road section type | Text |\n| `d_subzona` | Classificació de la zona on s'ha produït l'accident | Classification of the zone where the accident occurred | Text |\n| `d_superficie` | Estat de la calçada | Road surface condition | Text |\n| `d_tipus_via` | Tipus de via | Type of road | Text |\n| `d_titularitat_via` | Titularitat de la via | Road ownership | Text |\n| `d_tracat_altimetric` | Classificació del traçat altimètric | Classification of the altimetric layout | Text |\n\n### Condicions meteorològiques i ambientals\n\n| Camp | Descripció | Description | Tipus |\n|------|------------|-------------|-------|\n| `d_boira` | Presència de boira | Presence of fog | Text |\n| `d_climatologia` | Característiques de la climatologia | Weather characteristics | Text |\n| `d_lluminositat` | Condicions de lluminositat en el moment de l'accident | Lighting conditions at the time of the accident | Text |\n| `d_vent` | Classificació del vent | Wind classification | Text |\n\n### Factors d'influència\n\n| Camp | Descripció | Description | Tipus |\n|------|------------|-------------|-------|\n| `d_influit_boira` | Accident influït per la presència de boira | Accident influenced by the presence of fog | Text |\n| `d_influit_caract_entorn` | Accident influït per les característiques del terreny | Accident influenced by terrain characteristics | Text |\n| `d_influit_circulacio` | Accident influït per la circulació | Accident influenced by traffic | Text |\n| `d_influit_estat_clima` | Accident influït per l'estat del temps | Accident influenced by weather conditions | Text |\n| `d_influit_inten_vent` | Accident influït per la presència de vent | Accident influenced by the presence of wind | Text |\n| `d_influit_lluminositat` | Accident influït per lluminositat | Accident influenced by lighting | Text |\n| `d_influit_mesu_esp` | Accident influït per mesures especials de circulació | Accident influenced by special traffic measures | Text |\n| `d_influit_obj_calcada` | Accident influït per presència d'objecte en calçada | Accident influenced by presence of object on road | Text |\n| `d_influit_solcs_rases` | Accident influït per presència de solcs o rases | Accident influenced by presence of ruts or grooves | Text |\n| `d_influit_visibilitat` | Accident influït per manca de visibilitat | Accident influenced by lack of visibility | Text |\n\n### Classificació de l'accident\n\n| Camp | Descripció | Description | Tipus |\n|------|------------|-------------|-------|\n| `d_gravetat` | Gravetat de l'accident | Severity of the accident | Text |\n| `d_subtipus_accident` | Classificació de l'accident | Classification of the accident | Text |\n| `d_acc_amb_fuga` | Accident amb fuga | Hit-and-run accident | Text |\n| `tipacc` | Tipus d'accident | Type of accident | Text |\n\n### Informació temporal\n\n| Camp | Descripció | Description | Tipus |\n|------|------------|-------------|-------|\n| `hor` | Hora en què s'ha produït l'accident | Time when the accident occurred | Text |\n| `gruphor` | Franja del dia en què s'ha produït l'accident | Time period of the day when the accident occurred | Text |\n| `grupdialab` | Dia laborable o feiner | Working day or weekday | Text |\n| `tipdia` | Dia de la setmana en què s'ha produït l'accident | Day of the week when the accident occurred | Text |\n\n---\n\n## Kahoot\n\n[Kahoot - SQL - Accidents amb víctimes](https://create.kahoot.it/share/sql-accidents-amb-victimes/e7e9e633-fddc-4b36-b0e0-a190aa984119)\n\n![Kahoot](./imgs/kahoot.png)\n\n## Anàlisi de dades\n\nAra que ja tens carregades les dades, prepara amb els companys alguna consulta sobre les dades, per exemple, després de llegir aquesta notícia:\n\n![El punto kilométrico 333 de la AP-7, en donde hoy se ha registrado el accidente de un autobús ha causado la muerte de trece universitarias, no es un punto negro de siniestralidad, según diversas fuentes consultadas. https://www.lavanguardia.com/vida/20160320/40579951272/el-lugar-del-accidente-en-la-ap-7-no-es-un-punto-negro-de-siniestralidad.html](./imgs/LaVanguardia.png)\n\nBuquem quin va ser el punt quilomètric exacte i també si al voltant d'aquell punt kilomètric hi ha hagut altres accidents:\n\n![Captura de pantalla del dbeaver on fem una agregació dels accidents propers a aquell punt quilomètric](./imgs/ConsultaDbeaver.png)\n\n\u003cdetails\u003e\n\n\u003csummary\u003eConsulta i resultat\u003c/summary\u003e\n\n```sql\nSELECT Sum(f_morts)    AS morts,\n       Sum(f_victimes) AS victimes,\n       pk              AS \"Punt quilomètric\"\nFROM   accidents\nWHERE  via = 'AP-7'\n       AND pk BETWEEN 320 AND 340\nGROUP  BY via,\n          pk\nORDER  BY 1 DESC,\n          2 DESC \n```\n\n**Resultats:**\n\n| Morts | Víctimes | Punt quilomètric |\n|-------|----------|------------------|\n| 13 | 49 | 333.2 |\n| 1 | 10 | 328.1 |\n| 1 | 2 | 332.6 |\n| 1 | 2 | 321 |\n| 1 | 1 | 336.8 |\n| 1 | 1 | 336.7 |\n| 1 | 1 | 324.5 |\n| 1 | 1 | 334.3 |\n| 0 | 17 | 330 |\n| 0 | 10 | 325 |\n| 0 | 5 | 328 |\n| 0 | 4 | 332.5 |\n| 0 | 2 | 320.2 |\n| 0 | 2 | 322.9 |\n| 0 | 2 | 332.2 |\n| 0 | 2 | 337 |\n| 0 | 1 | 330.8 |\n| 0 | 1 | 336.5 |\n| 0 | 1 | 323 |\n| 0 | 1 | 322.3 |\n| 0 | 1 | 332.4 |\n\n\u003c/details\u003e\n\n---\n\n### Autor\n\nProjecte creat per [ctrl-alt-d](https://github.com/ctrl-alt-d)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctrl-alt-d%2FAccidentsAmbVictimes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctrl-alt-d%2FAccidentsAmbVictimes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctrl-alt-d%2FAccidentsAmbVictimes/lists"}