资源描述:
《《数据库库系统实现》PPT课件》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、数据元素的表示HowtolayoutdataondiskHowtomoveittomemoryPrinciplesarerathersimple,buttherearelotsofvariationsinthedetails主要内容如何将SQL数据类型表示成字段?如何将元组表示成记录?如何在存储块中表示记录或元组的集合?如何用块的集合表示和存储关系?如果不同的元组具有不同的记录大小,如何处理?如果记录大小因修改发生改变,如何处理?PrinciplesofDataLayout数据元素的表示Attributesofre
2、lationaltuples(orobjects)representedbysequencesofbytescalledfieldsFieldsgroupedtogetherintorecordsrepresentationoftuplesorobjectsRecordsstoredinblocksFile:collectionofblocksthatformsarelation(ortheextentofanobjectclass)OverviewDataItemsRecordsBlocksFilesMemory
3、here数据元素的表示作业Whatarethedataitemswewanttostore?asalary,anameadate,apicture…Whatwehaveavailable:Bytes8bits数据元素的表示作业Torepresent:Integer(short):2bytes(-32000…+32000)e.g.,35is0000000000100011arithmeticinterpretationbyhardwareReal,floatingpointnbitsformantissa,mfor
4、exponent….数据元素的表示作业Charactersvariouscodingschemessuggested,mostpopularisASCIITorepresent:Example(8bitASCII):A:01000001a:011000015:00110101LF:00001010数据元素的表示Booleane.g.,TRUEFALSE1111111100000000Torepresent:Applicationspecifice.g.,RED1GREEN2BLUE3YELLOW4…Canw
5、euselessthan1byte/code?Yes,butonlyifdesperate...数据元素的表示Dates,e.g.:Integer:#dayssinceJan1,19008chars:YYYYMMDD7chars:YYYYDDD10chars:YYYY-MM-DD(SQL2)(notYYMMDD!Why?)Time,e.g.Integer:secondssincemidnightchars:HH:MM:SS[.FF…](SQL2)Torepresent:数据元素的表示Stringofcharacte
6、rsNullterminatede.g.,-Lengthgivene.g.,-Fixedlengthctacta3Torepresent:数据元素的表示BagofbitsLengthBitsRecord-CollectionofrelatedfieldsE.g.:Employeerecord:namefield,salaryfield,date-of-hirefield,...数据元素的表示Typesofrecords:Mainchoices:FIXEDvsVARIABLEFORMATFIXEDvsVARIABLE
7、LENGTHASCHEMA(notrecord)containsfollowinginformation-numberoffields-typeofeachfield-orderinrecord-meaningofeachfieldFixedformat数据元素的表示Example:fixedformatandlengthEmployeerecord(1)E#,2byteinteger(2)E.name,10char.Schema(3)Dept,2bytecode46Ford0283Jones01Records数据
8、元素的表示Recorditselfcontainsformat;“SelfDescribing”Variableformat数据元素的表示4I524SdroF46Fieldnamecodescouldalsobestrings,i.e.tags(XMLasadatainterchangeformat)#FieldsCodeidentifyingfielda