Representing Data Elements Gayatri Gopalakrishnan
Contents Representing Relational Database Elements Representing Objects Representing Data Elements Records Reference
Representing Relational Database Objects CREATE TABLE StudentDetail( name CHAR(35), studentid INT(6) PRIMARY KEY, dept VARCHAR(50) );
Object as a Tuple How are an Object’s Methods stored Object Identifiers Accessing Methods Relation between objects Representing Objects
Representing Data Elements Character Data types Bit Strings Enumerated Types Integer and Float Dates and Times
Character Strings Fixed Length Character strings Described by SQL as CHAR (n), stored as an array of n bytes If actual string < n, the array is filled out with pad characters Default minimum size 1 byte maximum size 2000 bytes
Variable Length Character Strings Described by SQL as VARCHAR(n) Stored as an array of n+1 bytes Default minimum size 1 byte maximum size 4000 bytes Two representations of VARCHAR strings Length plus content Null Terminated string Character Strings contd..
Bits Described by SQL as BIT(n) If n is not divisible by 8, ignore the unused bits of the last byte Enumerated Types Attributes whose values take on a small fixed set of values Example Color = {RED,BLUE,GREEN,YELLOW}
Integer and Floats Integer Described by SQL as INTEGER Float Described by SQL as DECIMAL(p,s) p is the precision s is the scale Date and Time Date is represented as a fixed length character string Format
Date and Time contd.. Time is represented as a character string SQL standard allows value of TIME to include fractions of second – This can represented as VARCHAR or variable length values Time with time zone example 12:00: TIMESTAMP example :00: Timestamp can also include time zone
Thank You