### Implement Association with Attributes using C++ Class Source: https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm Demonstrates how to implement an association with attributes by creating a separate class. This example shows a 'WorksOn' class representing a one-to-one association between Employee and Project, including attributes like hours and date. ```cpp class WorksOn { private: Employee e; Project p; Hours h; char * date; public: // class methods }; ``` -------------------------------- ### Implement Constraints with Exception Handling in C++ Source: https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm Illustrates implementing constraints on class attributes using default values and exception handling. The example shows an Employee class with an 'age' attribute, enforcing a valid range (18-60) and throwing an 'AgeError' exception for invalid values. ```cpp class Employee { private: char * name; int age; // other attributes public: Employee() { // default constructor strcpy(name, ""); age = 18; // default value } class AgeError {}; // Exception class void changeAge( int a) { // method that changes age if ( a < 18 || a > 60 ) // check for invalid condition throw AgeError(); // throw exception age = a; } }; ``` -------------------------------- ### SQL Commands to Create Tables Source: https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm SQL commands for creating 'DEPARTMENT' and 'EMPLOYEE' tables. The 'DEPARTMENT' table stores department information, while the 'EMPLOYEE' table stores employee details and links to the 'DEPARTMENT' table via a foreign key. ```sql CREATE TABLE DEPARTMENT ( DEPT_ID INTEGER PRIMARY KEY, DNAME VARCHAR2(30) NOT NULL, LOCATION VARCHAR2(20) ); CREATE TABLE EMPLOYEE ( EMPID INTEGER PRIMARY KEY, ENAME VARCHAR2(50) NOT NULL, ADDRESS VARCHAR2(70), D_ID INTEGER REFERENCES DEPARTMENT ); ``` -------------------------------- ### Create Circle Table Schema and SQL Command Source: https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm Shows how to represent a 'Circle' class as a table in a Relational Database Management System (RDBMS). It includes the schema definition and the SQL command to create the 'CIRCLE' table with attributes like CID, coordinates, radius, and color. ```sql Schema for Circle Table: CIRCLE(CID, X_COORD, Y_COORD, RADIUS, COLOR) Creating a Table Circle using SQL command: CREATE TABLE CIRCLE ( CID VARCHAR2(4) PRIMARY KEY, X_COORD INTEGER NOT NULL, Y_COORD INTEGER NOT NULL, Z_COORD INTEGER NOT NULL, COLOR ); ``` -------------------------------- ### Implement One-to-One Bidirectional Association (C++) Source: https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm Demonstrates implementing a one-to-one bidirectional association between Project and Project_Manager. Both classes contain attributes representing the associated object, requiring careful management of links in both directions. ```cpp Class Project { private: // attributes Project_Manager pmgr; public: void setManager ( Project_Manager pm); Project_Manager changeManager(); }; class Project_Manager { private: // attributes Project pj; public: void setProject(Project p); Project removeProject(); }; ``` -------------------------------- ### Map 1:1 Association to SQL Tables (Department and Manager) Source: https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm Demonstrates mapping a one-to-one association between 'Department' and 'Manager' entities to relational database tables. It provides SQL commands to create both tables, assigning the primary key of one as a foreign key in the other. ```sql CREATE TABLE DEPARTMENT ( DEPT_ID INTEGER PRIMARY KEY, DNAME VARCHAR2(30) NOT NULL, LOCATION VARCHAR2(20), EMPID INTEGER REFERENCES MANAGER ); CREATE TABLE MANAGER ( EMPID INTEGER PRIMARY KEY, ENAME VARCHAR2(50) NOT NULL, ADDRESS VARCHAR2(70) ); ``` -------------------------------- ### Implement Optional Unidirectional Association (C++) Source: https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm Demonstrates implementing an optional unidirectional association where a Customer may or may not have a Current Account. A Current_Account object is included as an attribute in Customer, which can be set to NULL. ```cpp class Customer { private: // attributes Current_Account c; public: Customer() { c = NULL; } Current_Account getCurrAc() { return c; } void setCurrAc( Current_Account myacc) { c = myacc; } void removeAcc() { c = NULL; } }; ``` -------------------------------- ### SQL Command to Create Works_On Association Table Source: https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm SQL command to create the 'WORKS_ON' table, which implements a many-to-many association between 'EMPLOYEE' and 'PROJECT'. It includes foreign keys referencing both 'EMPLOYEE' and 'PROJECT' tables and defines a composite primary key. ```sql CREATE TABLE WORKS_ON ( EMPID INTEGER, PID INTEGER, HOURS INTEGER, START_DATE DATE, PRIMARY KEY (EMPID, PID), FOREIGN KEY (EMPID) REFERENCES EMPLOYEE, FOREIGN KEY (PID) REFERENCES PROJECT ); ``` -------------------------------- ### Implement One-to-One Unidirectional Association (C++) Source: https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm Shows how to implement a one-to-one unidirectional association between Department and Manager. A Manager object is included as a non-NULL attribute in the Department class. ```cpp class Department { private: // attributes Manager mgr; public: Department (/*parameters*/, Manager m) { mgr = m; } Manager getMgr() { return mgr; } }; ``` -------------------------------- ### Implement One-to-Many Bidirectional Association (C++) Source: https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm Shows the implementation of a one-to-many bidirectional association between Department and Employee using C++ STL list. The Department class maintains a list of Employees, and the Employee class holds a reference to its Department. ```cpp class Department { private: char * deptName; list emp; public: void addEmployee ( Employee e) { emp.push_back(e); } void removeEmployee( Employee e) { int index = find ( e, emp ); emp.erase(index); } }; class Employee { private: //attributes Department d; public: void addDept(); void removeDept(); }; ``` -------------------------------- ### Implement One-to-Many Unidirectional Association (C++) Source: https://www.tutorialspoint.com/object_oriented_analysis_design/ooad_quick_guide.htm Illustrates implementing a one-to-many unidirectional association between Employee and Dependent. A list of Dependents is maintained as an attribute within the Employee class using C++ STL list. ```cpp class Employee { private: char * deptName; list dep; public: void addDependent ( Dependent d) { dep.push_back(d); } void removeDeoendent( Dependent d) { int index = find ( d, dep ); dep.erase(index); } }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.