Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Bodgitt and scraper, flag question

 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi:
I have just downloaded the assignment, and I am trying to decipher the requerments. In the data section of the database it says:
Repeat to end of file
1 byte "deleted" flag. 0 implies valid record, 1 implies deleted record.
can someone tell me what is the location of this byte withen a record. Is is in the begining of the record, or the end or it.
thanks
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hanna,
You will need to verify this in your instructions. Mine state:

Data section.
Repeat to end of file:
1 byte "deleted" flag. 0 implies valid record, 1 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


So the deleted flag appears before each record:
  • Deleted flag
  • name (record 1)
  • location
  • ...
  • owner
  • Deleted flag
  • name (record 2)
  • location
  • ...
  • owner


  • Regards, Andrew
     
    Hanna Habashy
    Ranch Hand
    Posts: 532
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    hi Andrew:
    Thank you for your reply. I am going to write a simple test class to varify all the information. I have one more question. Is that mean the flag byte part of the record length or not?
    thanks
     
    Ranch Hand
    Posts: 54
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    This stumped me for a bit. The deleted flag could be considered part of a record (that's the way I think of it) but it's not part of the the schema. So, I'd say that yes, the deleted flag is part of a record.
    Rich
     
    Andrew Monkhouse
    author and jackaroo
    Posts: 12199
    280
    Mac IntelliJ IDE Firefox Browser Oracle C++ Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Hanna & Richard,

    Originally posted by Hanna Habashy:
    I am going to write a simple test class to varify all the information.


    Excellent. So you probably have already determined the answer to your question...

    Originally posted by Hanna Habashy:
    Is that mean the flag byte part of the record length or not?


    I believe you will find it is not part of the record length.
    My copy of the instructions state:


    Data section.
    Repeat to end of file:
    1 byte "deleted" flag. 0 implies valid record, 1 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


    So according to this, the record is the size as specified in the record length, and the deleted flag is outside of the record and not counted in the size.
    Symantically this is correct: the deleted flag logically cannot be part of the record since you have to read the record to find out whether it exists or not. Getting all metaphysical there
    Regards, Andrew
     
    Hanna Habashy
    Ranch Hand
    Posts: 532
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    confirmed. The delete falg byte is not part of the record length.
    This is according to the .db file, which belongs to my project. I think other projects may vary.
     
    Richard Everhart
    Ranch Hand
    Posts: 54
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    My instructions are the same as yours, Andrew. However, while the deleted flag is not logically part of a record, as you say, you still have to read the byte containing the deleted flag value when you read a record. So, therefore, the deleted flag, while not part of a database schema, at least to me, is still part of a record's length for purposes of reading the record.
    Rich
     
    What are your superhero powers? Go ahead and try them on this tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
      Bookmark Topic Watch Topic
    • New Topic