How to define user-defined types (Object-Oriented Database) in SQL Server 2017?

398 Views Asked by At

In our Database course in university, our reference book was Fundamentals of Database Systems by Elmasri. In Chapter 12 of this book, we were introduced to Object-Oriented database systems, in which User-Defined Types (UDTs) were treated like objects.

I want to create these UDTs in Microsoft SQL Server 2017, but there seems to be no syntax that correspond to the keywords in the examples of this chapter, such as INSTANTIABLE, FINAL, REF.

I have tried using the syntax CREATE TYPE <type-name> AS ( <definition> ) but it does not seem to work. However, the syntax CREATE TYPE <type-name> AS TABLE ( <definition> ) works in SQL Server Management Studio but I still cannot find equivalents for the keywords mentioned above.

The code (or pseudocode) below is one of the examples provided in the book, and I cannot implement this in SQL Server Management Studio

CREATE TYPE PERSON_TYPE AS (
NAME VARCHAR (35),
SEX CHAR,
BIRTH_DATE DATE,
PHONES USA_PHONE_TYPE ARRAY [4],
ADDR USA_ADDR_TYPE
INSTANTIABLE
NOT FINAL
REF IS SYSTEM GENERATED
INSTANCE METHOD AGE() RETURNS INTEGER;
CREATE INSTANCE METHOD AGE() RETURNS INTEGER
FOR PERSON_TYPE
BEGIN
RETURN /* CODE TO CALCULATE A PERSON’S AGE FROM
TODAY’S DATE AND SELF.BIRTH_DATE */
END;
);
0

There are 0 best solutions below