google / google/transit

Some Primary Key may by empty

Open
#605 0 comments 0 reactions 0 assignees View on GitHub
Change type: Functional GTFS-Fares
Dominant language
No language data
Stars
1.1k
Forks
225
Avg merge
7d 17h
Merged PRs (30d)
3

Description

### Describe the problem

I have made a quick revue of PK constraints, I have found some "easter egg" 🤗
5 PK cases :

| cases | table | PK | Presence |
| --- | --- | --- | --- |
| 1 | agency | agency\_id | Conditionally Required |
| 2 | fare\_leg\_rules | network\_id, from\_area\_id, to\_area\_id, from\_timeframe\_group\_id, to\_timeframe\_group\_id, fare\_product\_id | only fare\_product\_id is required, attemps PK may equal to fare\_product\_id |
| 3 | fare\_transfert\_rules | from\_leg\_group\_id, to\_leg\_group\_id, fare\_product\_id, transfer\_count, duration\_limit | only fare\_product\_id is required, attemps PK may equal to fare\_product\_id |
| 4 | transfers | from\_stop\_id, to\_stop\_id, from\_trip\_id, to\_trip\_id, from\_route\_id, to\_route\_id | none of thoses fileds are required into the table, may have an empty PK |
| 5 | attributions | attributions\_id | Optional |

So I think an empty PK is not practical (cases 1,4,5)
And a composite primary key equal to the real PK into source table (fare_product_id) bothers me (cases 2,3)

### Use cases

see above

### Proposed solution

solution ?
| Cases | table | PK | Presence proposal |
| --- | --- | --- | --- |
| 1 | agency | agency\_id | Required |
| 2 | fare\_leg\_rules | fare\_leg\_rule\_id | auto increment |
| 3 | fare\_transfert\_rules | fare\_transfert\_rule\_id | auto increment |
| 4 | transfers | transfer\_id | auto increment |
| 5 | attributions | attributions\_id | Required |

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.