« first day (1259 days earlier)      last day (1399 days later) » 

12:45 AM
@NonExistent As the topic says, Ask your question, and then hang around a while to see if an expert looks back at their screen and answers it!
 
 
1 hour later…
1:46 AM
@TehShrike can u please help me with this
 
@NonExistent I don't quite understand the question
You left some business logic unstated. Do tickets have records before they are sold, or are the ticket records created when they are sold?
The image of the schema doesn't help me much - I can understand the "bus" table but I'm guessing on most of the others
Can you describe in words the relationship between busses and tickets, and what the difficulty is? What do you need to represent?
 
2:05 AM
@TehShrike Tickets are recorded when they are sold
A trip can be done by many buses and a bus can do many trips, a bus has a section that has seats ordered by columns and rows, this seat, what i want is that when a ticket is sold the seat change of state from available to unavailable
Like in movie theathers, the rooms can display many movies, when selling the tickets you give the seat to a client and that seat becomes unavailable for that movie, and when changing of movie, the seats become available again for new clients
 
is a "trip" a permanent thing (a route from one city to another) or is it associated with a point in time?
 
by now it's a permanent thing like a route
 
what do you call the record that represents a trip at a point in time?
Do people buy tickets for trips as routes, or trips at a point in time?
 
in this image or where? what you mean with the second question?
 
right, I don't have any spanish vocabulary, sorry
 
2:11 AM
do you mean if people buy once for a ticket an will go on that route forever with the same ticket? in that case no, people buy tickets of trips at a point in time
 
When I buy a ticket, is it only valid at a given point in time? Or can I use it any one time when a bus is driving that route?
What do you call the thing that is a trip at a point in time, the thing that people buy tickets for?
 
is valid at a given point in time.
is valid at a given point in time.
would help if i set the table names in english?
 
m59
@TehShrike have you dealt with setting form validity with async functions in Angular in the latest beta releases? Weird stuff. I finally figured it all out.
 
@NonExistent it would make it so that I could read it, but you don't have to, you can just tell me the answer to that question
@m59 no, I actually haven't used any of the form validity stuff at all
The app I'm working on right now saves everything on change
 
m59
Ping me if ever you run into that.
I need it for that ensureUnique dealy and the usual approach doesn't work right anymore
 
2:16 AM
So if the server ever saves anything other than what they typed into the field, the field switches to that version as soon as the POST comes back
 
m59
cool
 
Fields flip to read-only as soon as the save operation begins
 
What you mean with "Thing", is it the table where i store that?
 
@NonExistent do you have a table in which a single row corresponds to a single trip at a single point in time?
@NonExistent the table, the object, the concept, yes
 
yes i have, but the trip will not be done at a single point in time, it will be done every week
 
2:21 AM
@NonExistent what is the name of that table/object/concept?
That's what a ticket is actually associated with, right?
A ticket must be linked to a weekly trip, and the date/time of the specific trip that the ticket is for
 
I'm editing the table names for u, wait a bit please. No, the ticket by now is associated with the seat
 
Do seats have a time?
 
How do you connect a ticket to the time of the trip?
 
but if i connect the ticket to the time of the trip, i won't know the seat of the bus
Here's the image
the db model with the table names in english
 
2:41 AM
@NonExistent that doesn't make any sense
I'm confused
If I buy a ticket, wouldn't it have 1. the bus I would be taking 2. my seat 3. where it was leaving from 4. where it was going to 5. what time it was leaving?
I'm not asking about your current schema, I'm asking about reality
If your current schema doesn't have a record somewhere that represents a trip at a point in time, then you need to add that table
and then tickets would need to be associated with a record in that table, as well as a seat record that was associated with some bus
 
yes, you're right, but that information can be called in a query that relate all those tables from the table 'TRIP_BUS' of the schema, the only thing that can't be taken is the seat i i relate the 'TICKET' to that table
the image i gave you had something wrong, this one is a correct
@TehShrike and how would i know the seat assigned to that ticket if seat isn't associated with that table, it's associated to bus
 
I see, so your trip_bus table is the record that has the time/schedule associated with it
 
@TehShrike Yes
 
Shouldn't tickets be associated with trip_bus?
 
@TehShrike yes it should, but if i associate it with trip_bus how will know the seat assigned to the ticket?
@TehShrike yes it should, but if i associate it with trip_bus how will know the seat assigned to the ticket?
 
2:56 AM
@NonExistent I assume tickets should also be associated with seats
To know what seats were already taken on a trip_bus, you would join on all the tickets, and then join to their seats.
 
but if i associate seats with ticket too then i'll get a circle of relations between BUS -> SECTION -> SEAT -> TICKET -> TRIP_BUS and then to BUS again (those are the table names check it in the [image] (i.stack.imgur.com/KbLD7.png))
 
is that a problem?
The reality of it is that a bus has multiple relations to a seat, right?
There's one relationship, which is just that the bus has seats
Then there's another relationship, which is that tickets are sold for seats on a bus
They are different relationships
The first one is permanent - the bus always has these seats
The second is specific to trip_bus - tickets are sold for a point in time, not for permanent rights to the seat
These are two different relationships
 
@TehShrike but then the database won't be a normalized one
 
I've never heard of the definition of a normalized database including "no cycles"
Which normal form would that relationship violate?
Relational databases represent graphs, but they don't have to represent trees
As long as your concept of a "seat" is solid - and you have one row in one table that represents a singular "seat" - you can have multiple other rows in your database that could have different relationships to that same seat
 
3:21 AM
@TehShrike Maybe there are not definition of normalized database includes no cycles, but i want to keep [data consistency] (codeproject.com/Articles/38655/…)
 
@NonExistent that is correct, but the problem in that case is not that there are cycles - the problem is that the same relationship is described multiple times. In that example, projects only have one kind of relationship to teams, so it's a problem that there are two ways to link to them in that first schema.
Your case is different - you actually have different ways that busses relate to seats.
It's the difference between "what seats does this bus have in it physically" and "what seats are taken on this bus for this scheduled trip"
Those are two different relationships. If you only describe the latter, then the only way that you could figure out what seats were in a bus physically was by looking at all of the tickets that had been sold, seeing what the seat numbers were, and inferring that those seats must be in the bus, since tickets were sold for them at some point in time
But that obviously won't fly
 
@TehShrike hmmmm, It's a bit difficult try to solve this without that cycle, do you think there could be another way?
 
@NonExistent Only if you don't represent one of those two relationships.
You can either not know what seats a bus has
 
what you mean?
 
Or you can not know what seat a ticket is associated with
If you want to know both those things, then your schema will need to have two ways that busses relate to seats.
And this is fine.
 
3:31 AM
hmmm, that's a solution that generates another problem jaja
 
The article you linked to presents cycles as a problem
But they're not really a problem
In that case, the cycle was a symptom of improperly representing a relationship
Cycles happen all the time in schemas with properly-represented relationships
 
well, the best recommendation you give me is that one? or can i do something better?
@TehShrike i mean the cycle?
 
The cycle isn't a problem, man
You can either represent these two relationships in your schema, or not
 
i catch it, but i also think that the database design can be changed or improved
 
Almost certainly
But as long as a "seat" is a concept that you represent in your schema
Busses are going to have multiple paths that lead to a seat, because they have multiple relationships to things
And those things have relationships that end up at seats
You can change that by not representing seats at all in your schema, maybe
But I wouldn't recommend that
 
3:45 AM
but then how will i assign the seat to a ticket?
@TehShrike well, thank you for take the time to answer me:D
 
@NonExistent you'd have to infer everything about seats. Tickets would have a "column" and "row" or maybe just a seat number, and when working with busses, you'd just have to know/assume what seats it had
But I think it would be better to actually represent the seats on a bus then to have it defined somewhere outside of your schema
The relationships are there, even if you don't put them in your schema.
 
you mean in the app
i've got a question, i i have two tables and i want to compare two values for example the PK of the tables, can i to this: "SELECT a.id FROM table1 a, table2 b WHERE a.PK = b.PK" if they are not related by a FK?
@TehShrike i mean if a.PK is 1 and b.PK is one, will that give me the result i want?
 
Yeah, you can put any comparison at all in an ON clause
Most of the time the comparisons are based on foreign keys, but you can relate rows together however you'd like
 
4:01 AM
ok, thanks:D
 

« first day (1259 days earlier)      last day (1399 days later) »