first commit
This commit is contained in:
commit
8c81ee28b7
3106 files changed
+474415
No files matched your search
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"folders": {},
|
||||
"connections": {
|
||||
"postgres-jdbc-18bb8d14e3a-4b7a96932eaa0782": {
|
||||
"provider": "postgresql",
|
||||
"driver": "postgres-jdbc",
|
||||
"name": "postgres",
|
||||
"save-password": true,
|
||||
"show-system-objects": true,
|
||||
"configuration": {
|
||||
"host": "localhost",
|
||||
"port": "5432",
|
||||
"database": "postgres",
|
||||
"url": "jdbc:postgresql://localhost:5432/postgres",
|
||||
"configurationType": "MANUAL",
|
||||
"type": "dev",
|
||||
"properties": {
|
||||
"connectTimeout": "20",
|
||||
"loginTimeout": "20",
|
||||
"escapeSyntaxCallMode": "callIfNoReturn"
|
||||
},
|
||||
"provider-properties": {
|
||||
"@dbeaver-show-non-default-db@": "false",
|
||||
"@dbeaver-show-template-db@": "false",
|
||||
"@dbeaver-show-unavailable-db@": "false",
|
||||
"show-database-statistics": "false",
|
||||
"@dbeaver-read-all-data-types-db@": "false",
|
||||
"read-keys-with-columns": "false",
|
||||
"@dbeaver-use-prepared-statements-db@": "false",
|
||||
"postgresql.dd.plain.string": "false",
|
||||
"postgresql.dd.tag.string": "false"
|
||||
},
|
||||
"auth-model": "native"
|
||||
}
|
||||
}
|
||||
},
|
||||
"virtual-models": {"postgres-jdbc-18bb8d14e3a-4b7a96932eaa0782":{"postgres":{"NHSBT":{"@properties":{"erd.diagram.state":{"serialized":"\u003cdiagram version\u003d\"1\" name\u003d\"empty\" time\u003d\"202312041909\"\u003e\u003centities\u003e\u003cdata-source id\u003d\"postgres-jdbc-18bb8d14e3a-4b7a96932eaa0782\"\u003e\u003centity id\u003d\"1\" name\u003d\"donor\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.donor\" order\u003d\"0\" font\u003d\"Segoe UI:9:0\" x\u003d\"340\" y\u003d\"400\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003centity id\u003d\"2\" name\u003d\"hospital\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.hospital\" order\u003d\"2\" font\u003d\"Segoe UI:9:0\" x\u003d\"600\" y\u003d\"40\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003centity id\u003d\"3\" name\u003d\"operation\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.operation\" order\u003d\"3\" font\u003d\"Segoe UI:9:0\" x\u003d\"20\" y\u003d\"180\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003centity id\u003d\"4\" name\u003d\"organ\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.organ\" order\u003d\"4\" font\u003d\"Segoe UI:9:0\" x\u003d\"380\" y\u003d\"180\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003centity id\u003d\"5\" name\u003d\"patient\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.patient\" order\u003d\"5\" font\u003d\"Segoe UI:9:0\" x\u003d\"380\" y\u003d\"280\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003centity id\u003d\"6\" name\u003d\"transplant_unit\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.transplant_unit\" order\u003d\"1\" font\u003d\"Segoe UI:9:0\" x\u003d\"340\" y\u003d\"60\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003c/data-source\u003e\u003c/entities\u003e\u003crelations\u003e\u003crelation name\u003d\"did_fk\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.operation.did_fk\" type\u003d\"fk\" pk-ref\u003d\"1\" fk-ref\u003d\"3\"/\u003e\u003crelation name\u003d\"hid_fk\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.transplant_unit.hid_fk\" type\u003d\"fk\" pk-ref\u003d\"2\" fk-ref\u003d\"6\"/\u003e\u003crelation name\u003d\"oid_fk\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.operation.oid_fk\" type\u003d\"fk\" pk-ref\u003d\"4\" fk-ref\u003d\"3\"/\u003e\u003crelation name\u003d\"pid_fk\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.operation.pid_fk\" type\u003d\"fk\" pk-ref\u003d\"5\" fk-ref\u003d\"3\"/\u003e\u003crelation name\u003d\"uid_fk\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.operation.uid_fk\" type\u003d\"fk\" pk-ref\u003d\"6\" fk-ref\u003d\"3\"/\u003e\u003c/relations\u003e\u003c/diagram\u003e"}}}}}},
|
||||
"connection-types": {
|
||||
"dev": {
|
||||
"name": "Development",
|
||||
"color": "255,255,255",
|
||||
"description": "Regular development database",
|
||||
"auto-commit": true,
|
||||
"confirm-execute": false,
|
||||
"confirm-data-change": false,
|
||||
"smart-commit": false,
|
||||
"smart-commit-recover": false,
|
||||
"auto-close-transactions": true,
|
||||
"close-transactions-period": 1800
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"resources":{"Scripts/Script-1.sql":{"default-datasource":"postgres-jdbc-18bb8d14e3a-4b7a96932eaa0782","default-catalog":"postgres","default-schema":"public"},"Scripts/Script.sql":{"default-datasource":"postgres-jdbc-18bb8d14e3a-4b7a96932eaa0782","default-catalog":"postgres","default-schema":"public"}}}
|
||||
Binary file not shown.
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"folders": {},
|
||||
"connections": {
|
||||
"postgres-jdbc-18bb8d14e3a-4b7a96932eaa0782": {
|
||||
"provider": "postgresql",
|
||||
"driver": "postgres-jdbc",
|
||||
"name": "postgres",
|
||||
"save-password": true,
|
||||
"show-system-objects": true,
|
||||
"configuration": {
|
||||
"host": "localhost",
|
||||
"port": "5432",
|
||||
"database": "postgres",
|
||||
"url": "jdbc:postgresql://localhost:5432/postgres",
|
||||
"configurationType": "MANUAL",
|
||||
"type": "dev",
|
||||
"properties": {
|
||||
"connectTimeout": "20",
|
||||
"loginTimeout": "20",
|
||||
"escapeSyntaxCallMode": "callIfNoReturn"
|
||||
},
|
||||
"provider-properties": {
|
||||
"@dbeaver-show-non-default-db@": "false",
|
||||
"@dbeaver-show-template-db@": "false",
|
||||
"@dbeaver-show-unavailable-db@": "false",
|
||||
"show-database-statistics": "false",
|
||||
"@dbeaver-read-all-data-types-db@": "false",
|
||||
"read-keys-with-columns": "false",
|
||||
"@dbeaver-use-prepared-statements-db@": "false",
|
||||
"postgresql.dd.plain.string": "false",
|
||||
"postgresql.dd.tag.string": "false"
|
||||
},
|
||||
"auth-model": "native"
|
||||
}
|
||||
},
|
||||
"mariaDB-18c7ce71acc-6d1e868e298d052a": {
|
||||
"provider": "mysql",
|
||||
"driver": "mariaDB",
|
||||
"name": "localhost",
|
||||
"save-password": true,
|
||||
"configuration": {
|
||||
"host": "localhost",
|
||||
"port": "3306",
|
||||
"url": "jdbc:mariadb://localhost:3306/",
|
||||
"configurationType": "MANUAL",
|
||||
"type": "dev",
|
||||
"auth-model": "native"
|
||||
}
|
||||
}
|
||||
},
|
||||
"virtual-models": {"postgres-jdbc-18bb8d14e3a-4b7a96932eaa0782":{"postgres":{"NHSBT":{"@properties":{"erd.diagram.state":{"serialized":"\u003cdiagram version\u003d\"1\" name\u003d\"empty\" time\u003d\"202312041909\"\u003e\u003centities\u003e\u003cdata-source id\u003d\"postgres-jdbc-18bb8d14e3a-4b7a96932eaa0782\"\u003e\u003centity id\u003d\"1\" name\u003d\"donor\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.donor\" order\u003d\"0\" font\u003d\"Segoe UI:9:0\" x\u003d\"340\" y\u003d\"400\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003centity id\u003d\"2\" name\u003d\"hospital\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.hospital\" order\u003d\"2\" font\u003d\"Segoe UI:9:0\" x\u003d\"600\" y\u003d\"40\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003centity id\u003d\"3\" name\u003d\"operation\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.operation\" order\u003d\"3\" font\u003d\"Segoe UI:9:0\" x\u003d\"20\" y\u003d\"180\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003centity id\u003d\"4\" name\u003d\"organ\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.organ\" order\u003d\"4\" font\u003d\"Segoe UI:9:0\" x\u003d\"380\" y\u003d\"180\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003centity id\u003d\"5\" name\u003d\"patient\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.patient\" order\u003d\"5\" font\u003d\"Segoe UI:9:0\" x\u003d\"380\" y\u003d\"280\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003centity id\u003d\"6\" name\u003d\"transplant_unit\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.transplant_unit\" order\u003d\"1\" font\u003d\"Segoe UI:9:0\" x\u003d\"340\" y\u003d\"60\"\u003e\u003cpath name\u003d\"NHSBT\"/\u003e\u003cpath name\u003d\"postgres\"/\u003e\u003c/entity\u003e\u003c/data-source\u003e\u003c/entities\u003e\u003crelations\u003e\u003crelation name\u003d\"did_fk\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.operation.did_fk\" type\u003d\"fk\" pk-ref\u003d\"1\" fk-ref\u003d\"3\"/\u003e\u003crelation name\u003d\"hid_fk\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.transplant_unit.hid_fk\" type\u003d\"fk\" pk-ref\u003d\"2\" fk-ref\u003d\"6\"/\u003e\u003crelation name\u003d\"oid_fk\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.operation.oid_fk\" type\u003d\"fk\" pk-ref\u003d\"4\" fk-ref\u003d\"3\"/\u003e\u003crelation name\u003d\"pid_fk\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.operation.pid_fk\" type\u003d\"fk\" pk-ref\u003d\"5\" fk-ref\u003d\"3\"/\u003e\u003crelation name\u003d\"uid_fk\" fq-name\u003d\"\u0026quot;NHSBT\u0026quot;.operation.uid_fk\" type\u003d\"fk\" pk-ref\u003d\"6\" fk-ref\u003d\"3\"/\u003e\u003c/relations\u003e\u003c/diagram\u003e"}}}}}},
|
||||
"connection-types": {
|
||||
"dev": {
|
||||
"name": "Development",
|
||||
"color": "255,255,255",
|
||||
"description": "Regular development database",
|
||||
"auto-commit": true,
|
||||
"confirm-execute": false,
|
||||
"confirm-data-change": false,
|
||||
"smart-commit": false,
|
||||
"smart-commit-recover": false,
|
||||
"auto-close-transactions": true,
|
||||
"close-transactions-period": 1800
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"resources":{"Scripts/Script-1.sql":{"default-schema":"public","default-datasource":"postgres-jdbc-18bb8d14e3a-4b7a96932eaa0782","default-catalog":"postgres"},"Scripts/Script-2.sql":{"default-datasource":"postgres-jdbc-18bb8d14e3a-4b7a96932eaa0782","default-catalog":"postgres","default-schema":"NHSBT"},"Scripts/Script.sql":{"default-schema":"public","default-datasource":"postgres-jdbc-18bb8d14e3a-4b7a96932eaa0782","default-catalog":"postgres"}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"id":"5a1df5db-fd99-4fe1-af14-86d0f0327a9c"}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Assignment1</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.jkiss.dbeaver.DBeaverNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
Binary file not shown.
@@ -0,0 +1,88 @@
|
||||
1. **hospital** Table
|
||||
Attributes:
|
||||
`hospital_id` (Primary Key)
|
||||
`hospital_name`
|
||||
`city`
|
||||
`postcode` (Unique)
|
||||
|
||||
```SQL
|
||||
CREATE TABLE hospital (
|
||||
hospital_id CHAR(3) CONSTRAINT hID_pk PRIMARY KEY,
|
||||
hospital_name VARCHAR(30),
|
||||
city VARCHAR(15),
|
||||
postcode VARCHAR(8) CONSTRAINT postcode_unique UNIQUE
|
||||
);
|
||||
```
|
||||
|
||||
2. **transplant_unit** Table
|
||||
Attributes:
|
||||
`unit_id` (Primary Key)
|
||||
`hospital_id` (Foreign Key referencing Hospital)
|
||||
`specialisation`
|
||||
|
||||
```SQL
|
||||
CREATE TABLE transplant_unit (
|
||||
unit_id CHAR(4) CONSTRAINT uID_pk PRIMARY KEY,
|
||||
hospital_id CHAR(3) CONSTRAINT hID_fk FOREIGN KEY REFERENCES hospital( hospital_id ),
|
||||
specialisation VARCHAR(20)
|
||||
);
|
||||
```
|
||||
|
||||
3. **organ** Table:
|
||||
Attributes:
|
||||
`organ_id` (Primary Key)
|
||||
`organ_type`
|
||||
|
||||
```SQL
|
||||
CREATE TABLE organ (
|
||||
organ_id CHAR(3) CONSTRAINT oID_pk PRIMARY KEY,
|
||||
organ_type VARCHAR(15)
|
||||
);
|
||||
```
|
||||
|
||||
4. **patient** Table:
|
||||
Attributes:
|
||||
`patient_id` (Primary Key)
|
||||
`patient_name`
|
||||
`age`
|
||||
|
||||
```SQL
|
||||
CREATE TABLE patient (
|
||||
patient_id CHAR(3) CONSTRAINT pID_pk PRIMARY KEY,
|
||||
patient_name VARCHAR(10),
|
||||
age INTEGER
|
||||
);
|
||||
```
|
||||
|
||||
5. **donor** Table:
|
||||
Attributes:
|
||||
`donor_id` (Primary Key)
|
||||
`donor_name`
|
||||
`age`
|
||||
|
||||
```SQL
|
||||
CREATE TABLE donor (
|
||||
donor_id CHAR(3) CONSTRAINT dID_pk PRIMARY KEY,
|
||||
donor_name VARCHAR(10),
|
||||
age INTEGER
|
||||
);
|
||||
```
|
||||
|
||||
6. **operation** Table
|
||||
Attributes:
|
||||
`operation_id` (Primary Key)
|
||||
`unit_id` (Foreign Key referencing TransplantUnit)
|
||||
`organ_id` (Foreign Key referencing Organ)
|
||||
`patient_id` (Foreign Key referencing Patient)
|
||||
`donor_id` (Foreign Key referencing Donor)
|
||||
|
||||
```SQL
|
||||
CREATE TABLE operation (
|
||||
operation_id CHAR(3),
|
||||
organ_id CHAR(3) CONSTRAINT oID_fk FOREIGN KEY REFERENCES organ( organ_id ),
|
||||
unit_id CHAR(4) CONSTRAINT uID_fk FOREIGN KEY REFERENCES transplant_unit( unit_id ),
|
||||
patient_id CHAR(3) CONSTRAINT pID_fk FOREIGN KEY REFERENCES patient( patient_id ),
|
||||
donor_id CHAR(3) CONSTRAINT dID_fk FOREIGN KEY REFERENCES donor( donor_id ),
|
||||
CONSTRAINT comp_op_key PRIMARY KEY ( operation_id, organ_id )
|
||||
);
|
||||
```
|
||||
Binary file not shown.
@@ -0,0 +1,39 @@
|
||||
Key Phrases:
|
||||
|
||||
1. Transplant operations [are carried out at specialist transplant units. They] are never split across more than one unit.
|
||||
An operation takes place at 1 Unit.
|
||||
|
||||
2. Each unit is based at one hospital only
|
||||
A unit can only be in 1 hospital
|
||||
|
||||
3. Specialises in one type of transplantation
|
||||
A unit has 1 specialisation
|
||||
|
||||
4. A unit can transplant the other types of organ which lie outside of its area of expertise.
|
||||
A unit does not specifically have to transplant it's specialisation
|
||||
|
||||
5. Some hospitals host more than one transplant unit.
|
||||
However some do not have a transplant unit.
|
||||
A hospital can have 0, 1 or many transplant units.
|
||||
|
||||
- **Transplant Operation**:
|
||||
- Involves a **Donor** [1:1] and a **Patient** [1:1].
|
||||
- Encompasses one or more **Organs** [1:M].
|
||||
- **Donor**:
|
||||
- May be associated with one or more **Transplant Operations** [1:M].
|
||||
- **Patient**:
|
||||
- May be associated with one or more **Transplant Operations** [1:M].
|
||||
- **Organ**:
|
||||
- Is involved in one or more **Transplant Operations** [M:1].
|
||||
- **Specialist Transplant Unit**:
|
||||
- Is tied to one **Hospital** [1:1].
|
||||
- Specialises in one type of **Organ** transplantation [o:1].
|
||||
- Can handle other types of **Organ** transplants outside its specialization [o:M].
|
||||
- **Hospital**:
|
||||
- Can host one or more **Specialist Transplant Units** [1:M].
|
||||
- Not all hospitals have a **Transplant Unit** [o:1].
|
||||
|
||||
`Hospital` -|---o-< `TransplantUnit`
|
||||
|
||||
- One hospital can have 0, 1 or many Units.
|
||||
- A unit must have a hospital, and only 1.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,90 @@
|
||||
1. **hospital** Table
|
||||
Attributes:
|
||||
`HospitalID` (Primary Key)
|
||||
`Name`
|
||||
`City`
|
||||
`Postcode` (Unique)
|
||||
|
||||
```SQL
|
||||
INSERT INTO hospital
|
||||
VALUES ('h01', 'Royal Infirmary', 'Manchester', 'M13 1AB'),
|
||||
('h02', 'St James University Hospital', 'Leeds', 'LE6 6JX'),
|
||||
('h03', 'Eye hospital', 'Manchester', 'M5 3AC'),
|
||||
('h04', 'Wythenshawe Hospital', 'Manchester', 'M22 4XD');
|
||||
```
|
||||
|
||||
2. **transplant_unit** Table
|
||||
Attributes:
|
||||
`unit_id` (Primary Key)
|
||||
`hospital_id` (Foreign Key referencing Hospital)
|
||||
`specialisation`
|
||||
|
||||
```SQL
|
||||
INSERT INTO transplant_unit
|
||||
VALUES ( 'u001', 'h01', 'Kidney (Renal)' ),
|
||||
( 'u002', 'h02', 'Kidney (Renal)' ),
|
||||
( 'u003', 'h01', 'Pancreas' ),
|
||||
( 'u004', 'h02', 'Liver' ),
|
||||
( 'u005', 'h04', 'Cardiothoracic' );
|
||||
```
|
||||
|
||||
3. **organ** Table:
|
||||
Attributes:
|
||||
`organ_id` (Primary Key)
|
||||
`organ_type`
|
||||
|
||||
```SQL
|
||||
INSERT INTO organ
|
||||
VALUES ( 'o1', 'kidney' ),
|
||||
( 'o2', 'heart' ),
|
||||
( 'o3', 'lung' ),
|
||||
( 'o4', 'pancreas' ),
|
||||
( 'o5', 'liver' );
|
||||
```
|
||||
|
||||
4. **patient** Table:
|
||||
Attributes:
|
||||
`patient_id` (Primary Key)
|
||||
`patient_name`
|
||||
`age`
|
||||
|
||||
```SQL
|
||||
INSERT INTO patient
|
||||
VALUES ( 'p03', 'ben', 58 ),
|
||||
( 'p04', 'jane', 27),
|
||||
( 'p05', 'joan', 50);
|
||||
```
|
||||
|
||||
5. **donor** Table:
|
||||
Attributes:
|
||||
`donor_id` (Primary Key)
|
||||
`donor_name`
|
||||
`age`
|
||||
|
||||
```SQL
|
||||
INSERT INTO donor
|
||||
VALUES ( 'd01', 'tom', 34 ),
|
||||
( 'd02', 'dick', 45 ),
|
||||
( 'd03', 'harry', 27 ),
|
||||
( 'd04', 'sue', 60 ),
|
||||
( 'd05', 'kate', 49 ),
|
||||
( 'd06', 'rose', 34 );
|
||||
```
|
||||
|
||||
6. **operation** Table
|
||||
Attributes:
|
||||
`operation_id` (Primary Key)
|
||||
`unit_id` (Foreign Key referencing TransplantUnit)
|
||||
`organ_id` (Foreign Key referencing Organ)
|
||||
`patient_id` (Foreign Key referencing Patient)
|
||||
`donor_id` (Foreign Key referencing Donor)
|
||||
|
||||
```SQL
|
||||
INSERT INTO operation
|
||||
VALUES ( 'op1', 'o1', 'u002', 'p03', 'd01' ),
|
||||
( 'op2', 'o2', 'u005', 'p04', 'd02' ),
|
||||
( 'op2', 'o3', 'u005', 'p04', 'd02' ),
|
||||
( 'op3', 'o4', 'u003', 'p05', 'd03' ),
|
||||
( 'op4', 'o5', 'u004', 'p05', 'd05' ),
|
||||
( 'op5', 'o5', 'u002', 'p03', 'd01' );
|
||||
```
|
||||
@@ -0,0 +1,52 @@
|
||||
3. List the names of patients who are at least fifty years old. Your query should always generate a list in which the names are sorted in alphabetical order. The ordering must not depend upon the order in which you entered data into your database.
|
||||
|
||||
```SQL
|
||||
SELECT patient_name
|
||||
FROM patient
|
||||
WHERE age >= 50
|
||||
ORDER BY patient_name;
|
||||
```
|
||||
|
||||

|
||||
|
||||
4. List the name of each type of organ, together with the total number of donations of that type of organ.
|
||||
|
||||
```SQL
|
||||
SELECT organ_type, COUNT( organ_type )
|
||||
FROM organ
|
||||
INNER JOIN operation ON operation.organ_id = organ.organ_id
|
||||
GROUP BY organ_type;
|
||||
```
|
||||
|
||||

|
||||
|
||||
5. List the identifiers of hospitals where a transplant has been performed, together with the number of transplant operations at the hospital.
|
||||
|
||||
```SQL
|
||||
SELECT hospital_id, COUNT( hospital_id )
|
||||
FROM transplant_unit
|
||||
INNER JOIN operation ON transplant_unit.unit_id = operation.unit_id
|
||||
GROUP BY hospital_id;
|
||||
```
|
||||
|
||||

|
||||
|
||||
6. Output the age of the oldest person who has donated in a hospital in Manchester.
|
||||
|
||||
```SQL
|
||||
SELECT age
|
||||
FROM donor
|
||||
WHERE donor_id IN (
|
||||
SELECT donor_id
|
||||
FROM operation
|
||||
WHERE unit_id IN (
|
||||
SELECT unit_id
|
||||
FROM transplant_unit
|
||||
WHERE hospital_id IN (
|
||||
SELECT hospital_id
|
||||
FROM hospital
|
||||
WHERE city LIKE '%Manchester%'
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
@@ -0,0 +1,59 @@
|
||||
1. **Hospital** Table:
|
||||
|
||||
Attributes:
|
||||
`HospitalID` (Primary Key)
|
||||
`Name`
|
||||
`Address`
|
||||
`City`
|
||||
`Postcode` (Unique)
|
||||
|
||||
The Hospital table is in 1NF as values would be atomic with no repeating groups. It is in 2NF as all attributes are dependent on the primary key with no partial dependencies, and it is in 3NF as there are no transitive dependencies; all attributes exclusively depend on the primary key.
|
||||
|
||||
2. **TransplantUnit** Table:
|
||||
|
||||
Attributes:
|
||||
`UnitID` (Primary Key)
|
||||
`HospitalID` (Foreign Key referencing Hospital)
|
||||
`Specialisation`
|
||||
|
||||
The TransplantUnit table is in 1NF as values would be atomic with no repeating groups. It is in 2NF as all attributes are dependent on the primary key with no partial dependencies, and it is in 3NF as there are no transitive dependencies; all attributes exclusively depend on the primary key.
|
||||
|
||||
3. **Organ** Table:
|
||||
|
||||
Attributes:
|
||||
`OrganID` (Primary Key)
|
||||
`OrganType`
|
||||
|
||||
The OrganType table is in 1NF as values would be atomic with no repeating groups. It is in 2NF as all attributes are dependent on the primary key with no partial dependencies, and it is in 3NF as there are no transitive dependencies; all attributes exclusively depend on the primary key.
|
||||
|
||||
4. **Donor** Table:
|
||||
|
||||
Attributes:
|
||||
`DonorID` (Primary Key)
|
||||
`Name`
|
||||
`Age`
|
||||
The Donor table is in 1NF as values would be atomic with no repeating groups. It is in 2NF as all attributes are dependent on the primary key with no partial dependencies, and it is in 3NF as there are no transitive dependencies; all attributes exclusively depend on the primary key.
|
||||
|
||||
5. **Patient** Table:
|
||||
|
||||
Attributes:
|
||||
`PatientID` (Primary Key)
|
||||
`Name`
|
||||
`Age`
|
||||
|
||||
The Patient table is in 1NF as values would be atomic with no repeating groups. It is in 2NF as all attributes are dependent on the primary key with no partial dependencies, and it is in 3NF as there are no transitive dependencies; all attributes exclusively depend on the primary key.
|
||||
|
||||
6. **Operation** Table:
|
||||
|
||||
We need an Operations table to record / capture information related to the operations themselves. This should include an ID for the operation as a primary key, the ID of the unit it was conducted in, the ID of the organ type used, the ID of the donor and the ID of the patient. This allows us to establish proper relationships to the other tables, and allows for a comprehensive record of the transplant process.
|
||||
This table also allows us to query easier, since all queries can be done on the one table to find essentially any information.
|
||||
Attributes:
|
||||
`OperationID` (Primary Key)
|
||||
`UnitID` (Foreign Key referencing TransplantUnit)
|
||||
`OrganTypeID` (Foreign Key referencing OrganType)
|
||||
`DonorID` (Foreign Key referencing Donor)
|
||||
`PatientID` (Foreign Key referencing Patient)
|
||||
|
||||
The Operation table is in 1NF as values would be atomic with no repeating groups. It is in 2NF as all attributes are dependent on the primary key with no partial dependencies, and it is in 3NF as there are no transitive dependencies; all attributes exclusively depend on the primary key.
|
||||
|
||||
In summary, the provided relational database model is in 3NF as each table has a primary key, and there are no transitive dependencies or non-prime attributes dependent on other non-prime attributes. This ensures the data is organized efficiently and minimizes redundancy.
|
||||
Whitespace-only changes.
@@ -0,0 +1,15 @@
|
||||
SELECT MAX(age) as oldest_donor
|
||||
FROM donor
|
||||
WHERE donor_id IN (
|
||||
SELECT donor_id
|
||||
FROM operation
|
||||
WHERE unit_id IN (
|
||||
SELECT unit_id
|
||||
FROM transplant_unit
|
||||
WHERE hospital_id IN (
|
||||
SELECT hospital_id
|
||||
FROM hospital
|
||||
WHERE city LIKE '%Manchester%'
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,32 @@
|
||||
CREATE TABLE hospital (
|
||||
hospitalID CHAR(3) CONSTRAINT hID_pk PRIMARY KEY,
|
||||
hospitalName VARCHAR(20),
|
||||
city VARCHAR(15),
|
||||
postcode CHAR(8) CONSTRAINT postcode_unique UNIQUE
|
||||
);
|
||||
CREATE TABLE transplantUnit (
|
||||
unitID CHAR(4) CONSTRAINT uID_pk PRIMARY KEY,
|
||||
hospitalID CHAR(3) CONSTRAINT hID_fk FOREIGN KEY REFERENCES hospital(HospitalID),
|
||||
specialisation VARCHAR(10)
|
||||
);
|
||||
CREATE TABLE organ (
|
||||
organID CHAR(3) CONSTRAINT oID_pk PRIMARY KEY,
|
||||
organType VARCHAR(15)
|
||||
);
|
||||
CREATE TABLE patient (
|
||||
patientID CHAR(3) CONSTRAINT pID_pk PRIMARY KEY,
|
||||
patientName VARCHAR(10),
|
||||
age INTEGER
|
||||
);
|
||||
CREATE TABLE donor (
|
||||
donorID CHAR(3) CONSTRAINT dID_pk PRIMARY KEY,
|
||||
donorName VARCHAR(10),
|
||||
age INTEGER
|
||||
);
|
||||
CREATE TABLE operation (
|
||||
operationID CHAR(3) CONSTRAINT opID_pk PRIMARY KEY,
|
||||
unitID CHAR(4) CONSTRAINT uID_fk FOREIGN KEY REFERENCES transplantUnit(unitID),
|
||||
organID CHAR(3) CONSTRAINT oID_fk FOREIGN KEY REFERENCES organ(organID),
|
||||
patientID CHAR(3) CONSTRAINT pID_fk FOREIGN KEY REFERENCES patient(patientID),
|
||||
donorID CHAR(3) CONSTRAINT dID_fk FOREIGN KEY REFERENCES donor(donorID)
|
||||
);
|
||||
@@ -0,0 +1,63 @@
|
||||
1. **Hospital** Table
|
||||
```SQL
|
||||
CREATE TABLE hospital (
|
||||
hospital_id CHAR(3) CONSTRAINT hID_pk PRIMARY KEY,
|
||||
hospital_name VARCHAR(30),
|
||||
city VARCHAR(15),
|
||||
postcode VARCHAR(8) CONSTRAINT postcode_unique UNIQUE
|
||||
);
|
||||
```
|
||||
|
||||
2. **Transplant_Unit** Table
|
||||
```SQL
|
||||
CREATE TABLE transplant_unit (
|
||||
unit_id CHAR(4) CONSTRAINT uID_pk PRIMARY KEY,
|
||||
hospital_id CHAR(3),
|
||||
specialisation VARCHAR(20),
|
||||
|
||||
CONSTRAINT hID_fk FOREIGN KEY ( hospital_id ) REFERENCES hospital( hospital_id )
|
||||
);
|
||||
```
|
||||
|
||||
3. **Organ** Table:
|
||||
```SQL
|
||||
CREATE TABLE organ (
|
||||
organ_id CHAR(3) CONSTRAINT oID_pk PRIMARY KEY,
|
||||
organ_type VARCHAR(15)
|
||||
);
|
||||
```
|
||||
|
||||
4. **Patient** Table:
|
||||
```SQL
|
||||
CREATE TABLE patient (
|
||||
patient_id CHAR(3) CONSTRAINT pID_pk PRIMARY KEY,
|
||||
patient_name VARCHAR(10),
|
||||
age INTEGER
|
||||
);
|
||||
```
|
||||
|
||||
5. **Donor** Table:
|
||||
```SQL
|
||||
CREATE TABLE donor (
|
||||
donor_id CHAR(3) CONSTRAINT dID_pk PRIMARY KEY,
|
||||
donor_name VARCHAR(10),
|
||||
age INTEGER
|
||||
);
|
||||
```
|
||||
|
||||
6. **Operation** Table
|
||||
```SQL
|
||||
CREATE TABLE operation (
|
||||
operation_id CHAR(3),
|
||||
organ_id CHAR(3),
|
||||
unit_id CHAR(4),
|
||||
patient_id CHAR(3),
|
||||
donor_id CHAR(3),
|
||||
|
||||
CONSTRAINT comp_op_key PRIMARY KEY ( operation_id, organ_id ),
|
||||
CONSTRAINT oID_fk FOREIGN KEY ( organ_id ) REFERENCES organ( organ_id ),
|
||||
CONSTRAINT uID_fk FOREIGN KEY ( unit_id ) REFERENCES transplant_unit( unit_id ),
|
||||
CONSTRAINT pID_fk FOREIGN KEY ( patient_id ) REFERENCES patient( patient_id ),
|
||||
CONSTRAINT dID_fk FOREIGN KEY ( donor_id ) REFERENCES donor( donor_id )
|
||||
);
|
||||
```
|
||||
@@ -0,0 +1 @@
|
||||
16
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Whitespace-only changes.
Binary file not shown.
Whitespace-only changes.
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Whitespace-only changes.
Binary file not shown.
Whitespace-only changes.
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Whitespace-only changes.
Binary file not shown.
Loaded 100 of 3106 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user