add class Monument type tuplename string address Address
- Slides: 65
Τύποι και Κλάσεις add class Monument type tuple(name: string, address: Address, description: string, closing_days: list(string), admission_fee: integer) add method increase_fee(amount: integer) in class Monument 12
Σύνθετα Αντικείμενα OID: OID 10 Name: Μαμά Καγκουρό Age: 4 Children: { [OID: OID 15 Name: Μωρό Κ. Age: 0. 5 Children: {}] } OID: OID 12 Name: Πέτρος Age: 40 Children: {OID 15} OID: OID 15 Name: Γιάννης Age: 15 Children: {} 14
Ιεραρχίες Τύπων και Κλάσεων Vehicle - Name - Weight - Color + Get. Name() + Get. Weight + Get. Color() Four. Wheels - Max. Velocity +Get. Max. Velocity() Van - Max. Cargo +Get. Max. Cargo() Bike - Num. Speeds +Get. Num. Speeds() Car - Num. Doors +Get. Num. Doors() 16
Υπερφόρτωση και πολυμορφισμός Vehicle - Name - Weight - Color + Get. Name() + Get. Weight + Get. Color() Four. Wheels - Max. Velocity +Get. Max. Velocity() Van - Max. Cargo +Get. Max. Cargo() +Get. Weight() Bike - Num. Speeds +Get. Num. Speeds() Car - Num. Doors +Get. Num. Doors() 17
Από το σύστημα O 2 add class City with extension type tuple(name: string, map: Bitmap, hotels: set(Hotel)) add class Monument type tuple(name: string, address: Address, description: string, closing_days: list(string), admission_fee: integer) 20
Από το σύστημα O 2 add class Address type tuple(street: string, city: City) add class Hotel type tuple(name: string, address: Address, facilities: list(string), stars: integer, rate: float) 21
Από το σύστημα O 2 add name Eiffel_tower: Monument, ή ισοδύναμα Eiffel_tower = new(Monument) add method increase_fee(amount: integer) in class Monument is private add class Historical_hotel inherits Monument, Hotel add method print_height(amount: float) in object Eiffel_tower 22
Object Definition Language, ODL interface Person ( extent people ) { attribute String name; attribute Struct Address { Unsigned Short number, String Street, String city_name} address; relationship Person spouse inverse Person: : spouse; relationship Set<Person> children inverse Person: : parents {order by birth_date } relationship List<Person> parents inverse Person: : children; void birth (in String name); Boolean marriage (in String person_name) raises (no_such_person); Unsigned Short ancestors (out Set<Person> all_ancestors) raises (no_such_person); void move (in String new_address); 24 };
Τα τμήματα της SQL: 1999 SQL/Framework SQL/Foundation SQL/PSM (Persistent Stored Modules) SQL/CLI (Call Level Interface) SQL/MED (Management of External Data) SQL Bindings/Temporal/OLAP/XML/OLB (Object Language Bindings, πρακτικά SQLJ) 27
SQL/CLI - τυπική ακολουθία εντολών Alloc. Env() Alloc. Connect() Alloc. Stmt() build the statement… Execute() -repeat as required. . . Transact() -repeat as required. . . Free. Stmt() Disconnect() Free. Connect() Free. Env() 31
SQL/PSM (Persistent Stored Modules) επιτρέπει το διαχωρισμό των εφαρμογών σε client και server stored modules CREATE FUNCTION sin SQL routines (FLOAT) RETURNS FLOAT 3 GL external routines EXTERNAL NAME υπολογιστικά πλήρης ! ‘LIB%MATHSUBSSINE’ LANGUAGE FORTRAN. . . 32
SQL/PSM -SQL Routines – compound statement – variable declaration – if statement – case statement – – – – – loop statement while statement repeat statement for statement leave statement return statement call statement assignment statement signal / resignal BEGIN…END; DECLARE var CHAR (6) IF subject (var) <> ‘urgent’ THEN … ELSE…; CASE subject (var) WHEN ‘SQL’ THEN… WHEN …; LOOP <SQL statements list> END LOOP; WHILE i < 100 DO … END WHILE; REPEAT … UNTIL i<100 END REPEAT; FOR result AS … DO … END FOR; LEAVE …; RETURN ‘urgent’; CALL procedure_x (1, 3, 5, ); SET x = ‘abc’; SIGNAL division_by_zero 33
SQL/MED (Management of External Data) επιτρέπει το registration, προσπέλαση και επερώτηση μη σχεσιακών δεδομένων μέσω SQL επιτρέπει να ορίσουμε ότι κάποιο πεδίο ενός πίνακα βρίσκεται αποθηκευμένο έξω από το DBMS CREATE FOREIGN TABLE My. Data(ID Integer, … ) SERVER My. Server OPTIONS (Filename /usr/pvassil/myda ta. txt, Delimiter ‘: ’) CREATE TABLE My. Gifs( ID Integer, picture DATALINK) INSERT INTO My. Gifs VALUES(3, DLVALUE( /usr/pvassil/mygi f. gif)) 34
Διακριτοί τύποι - Παραδείγματα CREATE DISTINCT TYPE CDN_DOLLAR AS DECIMAL (9. 2) CREATE DISTINCT TYPE US_DOLLAR AS DECIMAL (9. 2) CREATE TABLE SALES (ID INTEGER, US US_DOLLAR, CDN_DOLLAR) SELECT * FROM SALES WHERE CDN > US => fails!!!!! SELECT * FROM SALES WHERE CDN > CDN_DOLLAR(US) =>O. K!!!!! 39
ADTs - Ενθυλάκωση (Encapsulation) street (address)-> char(30) city (address)-> char(20) state (address)-> char(2) zip (address)-> integer street(address, char(30)) -> address city(address, char(20)) -> address state(address, char(2)) -> address zip(address, integer) -> address 43
ADTs -Κληρονομικότητα Οι ADTs κληρονομούν attributes και συμπεριφορά (functions) από τους υπερτύπους τους Υποστηρίζεται η πολλαπλή κληρονομικότητα shape point line polygon CREATE TYPE shape… CREATE TYPE point UNDER shape… CREATE TYPE line UNDER shape… CREATE TYPE polygon UNDER shape… 46
ADTs - Χρήση CREATE TYPE shape( refencing_system INTEGER, tolerance DECIMAL (8. 2), geometry BLOB (1 M)) CREATE TABLE real_estate_info (address, price money, owner char (40), property shape); UPDATE real_estate_info SET price = US_dollar (0. 9 * amount (price)) WHERE within_distance (property. . geometry, point (5, 5), miles (10)) SELECT D_mark (price), owner FROM real_estate_info WHERE overlaps (property. . geometry, square (5, 5, 25)) 47
ADTs - Substitutability CREATE TABLE real_estate_info ( price money, owner CHAR (40), property shape) INSERT INTO real_estate_info VALUES (US_dollar (100000), ‘Mr. S. White’, point (4, 4)) INSERT INTO real_estate_info VALUES (CDN_dollar (400000), ‘Mr. W. Green’, poly (point (4, 4), point (10, 10), point (12, 14))) INSERT INTO SALES VALUES (S_frank (150000), ‘Mrs. D. Black’, line (5, 5, 7, 8)) 48
ADTs - Substitutability Price Owner Property <us_dollar> amount: 100, 000 Mr. S. White <point> <cdn_dollar> amount: 400, 000 Mr. W. Green <poly> <s_frank> amount: 150, 000 ‘Mrs. D. Black’ <line> 49
ADTs - Late Binding SELECT owner, dollar_amount (price) FROM real_estate_info WHERE dollar_amount(price) < US_dollar(500000) θα καλέσει διαφορετική function στο runtime, ανάλογα με τον τύπο χρήματος που αποθηκεύτηκε στη στήλη PRICE (US_dollar, CDN_dollar, D_mark, S_frank, …) 50
ADT’S – Περαιτέρω χαρακτηριστικά CREATE TYPE emp_type UNDER person_t AS ( EMP_ID INTEGER, SALARY REAL) INSTANTIABLE % με data δηλαδή NOT FINAL % επιτρέπεται να έχει subtypes REF (EMP_ID) % με ότι REF’s σε αυτόν να % γίνονται μέσω του EMP_ID 51
Επώνυμοι Τύποι Γραμμής (Named Row Types) Ορίζονται από τον χρήστη χωρίς ενθυλακωμένη εσωτερική δομή CREATE ROW TYPE account_t (acctno INT, cust REF (customer_t), type CHAR (1), opened DATE, rate DOUBLE PRECISION, balance DOUBLE PRECISION); για να ορίσουν τον τύπο των rows σε ένα πίνακα CREATE TABLE account OF account_t (PRIMARY KEY acctno ); 53
Τύποι αναφοράς (Reference Types) Διευκολύνουν τη συσχέτιση τύπων γραμμής CREATE ROW TYPE account_t (acctno INT, cust REF (customer_t), type CHAR (1), opened DATE, rate DOUBLE PRECISION, balance DOUBLE PRECISION); Οι αναφορές μπορούν να έχουν εμβέλεια (scope) CREATE TABLE account OF account_t (PRIMARY KEY acctno, SCOPE OF cust IS customer ); Μπορούμε να αναφερθούμε μόνο σε “top level” εγγραφές 54
Εκφράσεις μονοπατιών - Path Expressions Τα references μπορούν να χρησιμοποιηθούν σε path expressions SELECT a. acctno, a. cust->name FROM account a WHERE a. cust->address. . city = “Hollywood” AND a. balance > 1000000; 56
ADT’s & Row Types: Subtyping Ένας row type μπορεί να είναι υποτύπος ενός ή περισσότερων row types, κληρονομώντας attributes και συμπεριφορά από αυτούς CREATE TYPE employee_t (name CHAR (20), salary DECIMAL (10, 2)) CREATE TYPE manager_t UNDER employee (bonus DEMICAL (10, 2)) CREATE TYPE ssummer_stundent_t UNDER employee (school VARCHAR (30)) 59
ADT’s & Row Types: Ιεραρχίες Πινάκων • Για τη μοντελοποίηση ιεραρχιών πινάκων (super/sub collections) CREATE TABLE employees OF employee_t CREATE TABLE managers OF manager_t UNDER employees CREATE TABLE summer_stundents OF summer_stundents_t UNDER employees • Ερωτήσεις στον πίνακα employees επιστρέφουν rows ΚΑΙ από τα sub-tables του! 60
Κατηγόρημα TYPE (TYPE Predicate) CREATE TABLE real_estate_info (price money, owner CHAR (40), property real_estate) 62
Κατηγόρημα TYPE Late binding SELECT price, owner, property FROM real_estate_info WHERE TYPE (price) IN (us_dollar) Αλλαγή του τύπου μιας έκφρασης σε έναν από τους υποτύπους του SELECT TREAT (price AS us_dollar), owner, property FROM real_estate_info WHERE TYPE (price) IN (us_dollar) 63
Εμείς θα θέλαμε στο μέλλον και. . . CREATE ROW TYPE employee ( id INTEGER, name VARCHAR(30), address, manager REF (employee), projects SET (REF (project)), children LIST (REF (PERSON)), hobbies MULTISET (VARCHAR (20))) 65
- Http protocol description
- Public class person private string name
- Class maths student student1 class student string name
- Click to add titleclick to add subtitle
- Click to add titleclick to add subtitle
- Click to add titleclick to add subtitle
- Const char * vs char * const
- 3600000/24
- Why washington monument two different colors
- Jochen gerz monument contre le racisme
- Prehistoric monument dan word
- Monument to multiculturalism
- Root cause analysis tools
- Josh gloria bustamante
- Tilly van hall
- Washington monument
- Monument
- Monument 500 million population
- Devils tower national monument
- Oscar wilde monument
- Lancer monument
- Monument energy
- Monument energy
- Monument
- Monument
- Chris jeub monument academy
- Teardrop monument gift from russia
- Monument energy
- What is the name of the monument
- Washington monument google earth
- Logical memory is broken into
- Interface calculator public int add(int a int b) class test
- String data type example
- String data type
- Integer real char string boolean
- The three keys to a quality salad are
- Public class employee
- Class string
- Public class vehicle private string name protected vehicle
- Public class person private string name
- Public class animal private string name
- Class boo boo(string s) boo()
- C string class
- Public class telephone { private string number
- Private string
- Mainstring
- Private string java
- Public class employee private string name
- Public class person private string name
- Class test public static void main
- Private string name;
- Which type of address is this: a3:34:45:11:92:f1
- Class b ip address example
- Class d and e ip address
- Is hyper v type 1 or type 2
- Type 1 and type 2 muscle fibres
- Pregnancy test keeps saying error
- Type 2 vs type 1 error
- Rock cycle sedimentary
- Narrow band theory in sport
- Sublimation psychology
- Myotonic dystrophy
- Null and deflection type instruments
- ıf clauses type 1 exercises
- Hypothesis type 1 error
- What is the null hypothesis