PromptBase
Upgrade
Close icon
General
Home
Marketplace
Create
Hire
Login
Chat
Sell
Explore

Prompt Details

Model
Chat - GPT-4 (gpt-4)
Token size
157 ($0.00470 / call)
Example input
A company dedicated to the installation of made-to-measure bedrooms for young people wants to create a database where the sales and assemblies are reflected, for which it is taken into account: - Each bedroom model must be assembled by at least two fitters. - The same assembler can assemble several bedroom models. - We are interested in knowing the model code of each bedroom model. - The same fitter can fit the same model on different dates. We are interested in to know the date on which each assembly was carried out. - We are interested in the assembler's NIF, name, address, contact telephone number and the number of bedrooms he has assembled of each model. bedrooms he has assembled of each model. - Each model of bedroom can be bought by one or more clients and the same client can buy one or more bedrooms. can buy one or more bedrooms. We are interested in the customer's NIF, name, address, telephone number and date of purchase,
Example output
Based on the given requirements, we can outline the following Entity-Relationship Diagram components: Entities (Subjects) and Attributes: 1. **Hospital** - HospitalID (Primary Key) - Name - Address - MaxBeds (The maximum number of beds in the hospital) 2. **SpecialtyRoom** - RoomID (Primary Key) - HospitalID (Foreign Key) - Specialty - NumBeds (Number of beds in the room) 3. **Staff** - StaffID (Primary Key) - HospitalID (Foreign Key) - Name - Role (Nurse or Internal Staff, not a doctor) - Shift (Morning, Afternoon, Night) - Salary (Annual Gross Salary) 4. **Doctor** - DoctorID (Primary Key) - HospitalID (Foreign Key) - Name - Specialty 5. **Patient** - PatientID (Primary Key) - RoomID (Foreign Key) - BedNumber - Name - Diagnosis Relationships (Verbs) and their Types: 1. **Hospital** contains **SpecialtyRoom**. - One-to-Many (1,N): A hospital is composed of multiple specialty rooms, but each specialty room belongs to only one hospital. 2. **Hospital** employs **Staff**. - One-to-Many (1,N): A hospital employs many staff members, but each staff member works at only one hospital. 3. **Hospital** employs **Doctor**. - One-to-Many (1,N): Each doctor depends on one hospital and cannot belong to several hospitals. 4. **SpecialtyRoom** accommodates **Patient**. - One-to-Many (1,N): A specialty room can accommodate multiple patients, but each patient is assigned to only one specialty room and one bed within that room. In this scenario, there is no direct relationship between the Staff/Doctor and the Patient in the given requirements, although in a real-world application, you would likely have relationships representing which staff or doctor is treating which patient. **Relational Model Tables**: 1. **Hospital** - HospitalID (PK) - Name - Address - MaxBeds 2. **SpecialtyRoom** - RoomID (PK) - HospitalID (FK) - Specialty - NumBeds 3. **Staff** - StaffID (PK) - HospitalID (FK) - Name - Role - Shift - Salary 4. **Doctor** - DoctorID (PK) - HospitalID (FK) - Name - Specialty 5. **Patient** - PatientID (PK) - RoomID (FK) - BedNumber - Name - Diagnosis Now, let's create the SQL code for these tables: ```sql CREATE TABLE Hospital ( HospitalID INT PRIMARY KEY, Name VARCHAR(255), Address VARCHAR(255), MaxBeds INT ); CREATE TABLE SpecialtyRoom ( RoomID INT PRIMARY KEY, HospitalID INT, Specialty VARCHAR(255), NumBeds INT, FOREIGN KEY (HospitalID) REFERENCES Hospital(HospitalID) ); CREATE TABLE Staff ( StaffID INT PRIMARY KEY, HospitalID INT, Name VARCHAR(255), Role VARCHAR(50), Shift CHAR(1), Salary DECIMAL(10,2), FOREIGN KEY (HospitalID) REFERENCES Hospital(HospitalID) ); CREATE TABLE Doctor ( DoctorID INT PRIMARY KEY, HospitalID INT, Name VARCHAR(255), Specialty VARCHAR(255), FOREIGN KEY (HospitalID) REFERENCES Hospital(HospitalID) ); CREATE TABLE Patient ( PatientID INT PRIMARY KEY, RoomID INT, BedNumber INT, Name VARCHAR(255), Diagnosis TEXT, FOREIGN KEY (RoomID) REFERENCES SpecialtyRoom(RoomID) ); ``` In these relationships: - The `HospitalID` in `SpecialtyRoom`, `Staff`, and `Doctor` is a foreign key that references the `Hospital` table to ensure that rooms, staff, and doctors are associated with one and only one hospital. - The `RoomID` in the `Patient` table is a foreign key that references the `SpecialtyRoom` table to ensure that a patient is assigned to a specific room. Would you like any more help or need the SQL code adjusted in any way?
πŸ€– GPT

Best Sql Prompt

Add to Cart
Instant accessInstant access
Usage rightsCommercial use
Money-back guaranteeMoney‑back
By purchasing this prompt, you agree to our terms of service
GPT-4
Tested icon
Guide icon
Free credits icon
Streamline databases effortlessly πŸ› οΈ, auto-generate SQL code πŸ“Š, intuitive mapping mastery 🌐, and sophisticated schema designs πŸ–‹οΈ Elevate your database game with the ultimate EDR Diagram Maker! πŸš€ Seamlessly translate complex relationships into clear diagrams. πŸ“ˆ Dramatically simplify your database creation process 🧩, with the smart tool that provides ready-to-use SQL code. πŸ“‘ This prompt is your key to unlocking a world of efficient, error-free database architecture!
...more
Added over 1 month ago
Report
  • Reviews for this prompt (1)
Browse Marketplace