Presentation is loading. Please wait.

Presentation is loading. Please wait.

Module 4: Data Objects. Overview Tables are the main objects that store data Indexes, views, stored programs and other objects are the support structures.

Similar presentations


Presentation on theme: "Module 4: Data Objects. Overview Tables are the main objects that store data Indexes, views, stored programs and other objects are the support structures."— Presentation transcript:

1 Module 4: Data Objects

2 Overview Tables are the main objects that store data Indexes, views, stored programs and other objects are the support structures Various table types compared based on data organization Various index types compared Native and non-native data type support Block-level storage architecture

3 Schema Objects – Table Tables are the primary objects that store data in rows and columns Each DBMS offers different types of tables to support different access needs with optimal performance and extended functionality as the goals OracleSQL Server Heap-Organized Table Heap Clustered Table- Partitioned Table Nested TableXML datatype Temporary Table External TableLinked Server Object TableTable Types Index-organized Table Clustered Index Table Types in Oracle and SQL Server

4 Putting Data in the Table Heap is the default form of data organization in a table, where data is stored in an unordered manner Allocation units can extend beyond themselves Oracle’s index organized tables store data in a B-tree structure in primary key order Oracle and SQL Server offer local and global temporary tables to store transient application data Compression is necessary

5 Demonstration 1: Reviewing Large Allocation Units In this demonstration you will see how to: Create a query to view allocation units Determine why multiple results for a single index might be provided.

6 SQL Server Table Structures Clustered Index Structure in SQL Server Sysindexes Root node Intermediate level Leaf node / data pages A-Z W-ZA-DE-H… … Debra Andy Charlie

7 Indexes Index Structures in Oracle and SQL Server Index schemeOracleSQL Server B-tree UniqueYes B-tree Non-uniqueYes B-tree CompositeYes (32 cols)Yes (16 cols) B-tree AscendingYes B-tree DescendingYes B-tree ClusterYes B-tree Reverse keyYesNo B-tree Key compressedYes No B-tree Function-basedYesNo B-tree Index organized tableYesYes (clustered) B-tree PartitionedYesNo BitmapYes (30 cols)No 1 Bitmap JoinYesNo 1

8 Constraints Constraints are data integrity rules defined on columns of a table to enforce certain business rules OracleSQL Server NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY DEFAULT CHECK Constraints in Oracle and SQL Server

9 Triggers Trigger Types Compared FeatureOracleSQL Server DML – INSERTYes DML – UPDATEColumn/RowRow DML – DELETEYes Timing – BEFOREYesYes (INSTEAD OF) Timing – AFTERYes LevelRow/StatementRow Views – INSTEAD OFYes Multiple triggers per actionYesYes (first/last specified) DDL TriggersNoYes Single trigger for multiple actionsYes

10 Views Both Oracle and SQL Server offer views based on simple queries involving a single table and complex queries based on multiple tables Indexed views in SQL Server is the only type of view which actually stores data Oracle and SQL Server offer updatable views with INSTEAD OF triggers and WITH CHECK OPTION constraint View TypeOracleSQL Server Simple views Yes Join views Yes Partitioned views Yes Updatable views Yes Inline views Yes Object views YesNo Indexed views NoYes View Types in Oracle and SQL Server

11 Number Generation and New Names CREATE SEQUENCE SomeNewNumbers START WITH 0 INCREMENT BY 1 ORACLE: Sequence ( 0, 1, 2, 3, 4, ………. CREATE TABLE ASchema.ATable ( Id int IDENTITY(0,1), Information nvarchar(12) ) SQL Server: Identity (0, 1, 2, 3, 4, ……….. CREATE TABLE dbo.Globally_Unique_Data (guid uniqueidentifier CONSTRAINT Guid_Default DEFAULT NEWSEQUENTIALID() ROWGUIDCOL, Employee_Name varchar(60) CONSTRAINT Guid_PK PRIMARY KEY (guid) ); SQL Server: Global Unique Identifiers ( B2794358-DA6A-DD11-829F-001E685F0BC5… CREATE SYNONYM MyProduct FOR TheSchema.TheProduct; Either: Synonyms

12 Character-Based Data Types Character-based data types in Oracle and SQL Server OracleSQL Server Data TypeSize (bytes)Data TypeNumber of Chars Size in bytes Char1 to 2000Char1 to 80001 to 8000 fixed NChar1 to 2000 (fewer chars)NChar1 to 40002 to 8000 fixed Varchar1 to 4000Varchar Varchar(max) 1 to 8000 1 to 2 31 -1 0 to 8000 0 to 2 GB NVarchar1 to 4000 (fewer chars)NVarchar NVarchar(max) 1 to 4000 1 to 2 30 -1 0 to 8000 0 to 2 GB Varchar21 to 4000 NVarchar21 to 4000 (fewer chars) LONG1 to 2 31 Text, Varchar(max) 1 to 2 31 -10 to 2 GB CLOB1 to 2 32 Text, Varchar(max) 1 to 2 31 -10 to 2 GB NCLOB1 to 2 32 Ntext, Nvarchar(max) 1 to 2 30 -10 to 2 GB

13 Numeric Data Types Numeric data types in Oracle and SQL Server OracleSQL Server Number(19,0)BigInt Int or Number(10,0)Int SmallInt or Number(6,0)SmallInt Number(3,0)TinyInt Number(p,0)Decimal(p,s) Number(p,0)Numeric(p,s) Float or DoublePrecision or Number(38) Float Number(1)Bit Number(19,4)Money Number(10,4)SmallMoney

14 Date and Time Types OracleSQL Server Data TypeValuesData TypeValues DateDate and time to secondsSmallDateTimeDate and time to seconds DateTime Date and time with fractional seconds to 1/300 or 3.33 milliseconds Calendar01/01/1753 AD – 01/06/9999 AD (DMY) Timestamp (TS) Date and time with fractional seconds (9 digits) DateTime2 (DT2) Date and time with fractional seconds (7 digits) Timestamp with time zone (TSTZ) Like TS with zones Timestamp with local time zone (TSLTZ) Like TS with relative zones to users DateTimeOffsetLike DT2 with time zone offsets Calendar – Julian 01/01/4712 BCE - 12/31/4712 CE Calendar – Gregorian 01/01/0001 AD – 31/12/9999 AD (DMY) Daylight Savings Time Support Yes Daylight Savings Time Support No DATEDate only – Gregorian TIME Time only with fractional seconds (7 digits)

15 Binary Data Types OracleSQL Server BLOBImage, Varbinary(max) RawImage, Varbinary(max) Long RawImage, Varbinary(max) BFileSimilar to Varbinary(max) Filestream BLOB/Raw(n)Binary(n) BLOB/Raw(n)Varbinary(n), Varbinary(max) Binary data types in Oracle and SQL Server

16 Demonstration 2: Creating a Table In this demonstration you will see how to: Create a table taking advantage of filegroups for different types data structures. Review the results using SSMS

17 Non-Native Data Types – Beyond Relational SpatialHierarchy

18 Demonstration 3: Beyond Relational In this demonstration you will see how to: Define geometric shapes Define an organizational structure for a company

19 Oracle and SQL Server Block-Level Data Organization Microsoft SQL Server Data Page Row Offsets Oracle Data Block Row Offsets Page Header Data Row 1 Data Row 2 Data Row 3 Free Space Block Header Free Space Data Row 3 Data Row 2 Data Row 1 321 123

20 Review Reviewed the types of tables found in Oracle and discussed equivalents in SQL Server for heaps, index organized tables and temporary tables Discussed the supporting schema objects such as indexes and views Examined the numeric, character and binary data types Implementation of user-defined data types in Oracle and SQL Server Comparison of block-level data storage


Download ppt "Module 4: Data Objects. Overview Tables are the main objects that store data Indexes, views, stored programs and other objects are the support structures."

Similar presentations


Ads by Google