Database schema
The database that URLyBird uses contains the following fields: Field descriptive name Database field name Field length Detailed description
Hotel Name name 64 The name of the hotel this vacancy record relates to
City location 64 The location of this hotel
Maximum occupancy of this room size 4 The maximum number of people permitted in this room, not including infants
Is the room smoking or non-smoking smoking 1 Flag indicating if smoking is permitted. Valid values are "Y" indicating a smoking room, and "N" indicating a non-smoking room
Price per night rate 8 Charge per night for the room. This field includes the currency symbol
Date available date 10 The single night to which this record relates, format is yyyy/mm/dd.
Customer holding this record owner 8 The id value (an 8 digit number) of the customer who has booked this. Note that for this application, you should assume that customers and CSRs know their customer ids. The system you are writing does not interact with these numbers, rather it simply records them. If this field is all blanks, the record is available for sale.
Regards, Richard
)These length of fields are 'byte' type,they have to be convert other types(likes 'double rate' or'boolean smoking')?
If not,what should I do convert the all strings to relational types?
2)Many of friends think that the record length is fixed(simply represent as "byte recordSize=64+64+4+1+8+10+8;",correct?),whether it implys that following or not?
A.I can declare it as a CONSTANT.
B.I don't have to modify the field count and length but invoking them.
1)These length of fields are 'byte' type,they have to be convert other types(likes 'double rate' or'boolean smoking')?
If not,what should I do convert the all strings to relational types?
2)Many of friends think that the record length is fixed(simply represent as "byte recordSize=64+64+4+1+8+10+8;",correct?),whether it implys that following or not?
A.I can declare it as a CONSTANT.
B.I don't have to modify the field count and length but invoking them.
kktec<br />SCJP, SCWCD, SCJD<br />"What we observe is not nature itself, but nature exposed to our method of questioning." - Werner Heisenberg
But your file header probably indicates the
length of each field.
Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
2 byte numeric, number of fields in each record
Schema description section.
Repeated for each field in a record:
1 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
1 byte numeric, field length in bytes
end of repeating block
Data section.
Repeat to end of file:
1 byte flag. 00 implies valid record, 0xFF implies deleted record
Record containing fields in order specified in schema section, no separators between fields, each field fixed length at maximum specified in schema information
End of file
Regards, Richard
Regards, Richard
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
With the price field - do you have to do any work at all with it? Is there any verification to be done on that field / any calculations? If not, then why not just leave it as a String?
With the date field - do you have to do any calculations on it? If you have to only allow bookings within a certain timeframe, then you might have to convert this to one of the date classes so you can do comparisons.
Regards, Richard
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Another future enhancement might be that we need to manage more tables simultaneously.
If we are reading the schema from the physical file, and treating each record as a String, then the same Data class code can be used unchanged for additional tables.
Regards, Richard
Originally posted by Andrew Monkhouse:
Another future enhancement might be that we need to manage more tables simultaneously.
Originally posted by Richard Jackson:
The "more tables" means what?
Originally posted by Richard Jackson:
when I add some getXX or setXX methods to the field class,I dont know if the above fields (or several fields,like date/smoking/rate) should be converted to suitable format
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
As for the date field - you may want to see if there are any instructions about whether you are allowed to accept bookings within a certain period of the start of room occupancy. If so, then you may have to convert the String representation of the date into a real date format so that you can do date comparisons.
Consider whether you need the fields in a format other than a String in order to complete the assignment.
Regards, Richard