Question

Write SQL statements that will create a Database, three Entities and the necessary tables/columns of a...

Write SQL statements that will create a Database, three Entities and the necessary tables/columns of a Hospital. Do not forget to submit an ER diagram to show the relationship and Cardinality also

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer)
CREATE TABLE Patient(patientid int primary key, pname varchar, address varchar, amount int, ptype varchar);

create table hospital (hospitalid int primary key, hname varchar, htype varchar);

create table doctor (doctorid int primary key, dname varchar, specialization varchar, hospitalid int, status varchar, FOREIGN KEY (hospitalid) REFERENCES hospital(hospitalid));

create table billing (billingid int primary key, patientid int, doctorid int, fees int, billdate date, FOREIGN KEY (patientid) REFERENCES patient(patientid), FOREIGN KEY (doctorid) REFERENCES doctor(doctorid));

hospital : Doctor = 1:MANY relationship.
Patient : Billing = 1:1 relationship
Billing : Doctor = 1:1 relationship.


The ERD is as below:

Patient Billing PK patientid pname address amount PK billingid FK patientio FK doctorid billdate hospital Doctor PK hospitalid PK doctorid hname dname htype specialization FK hospitalid status

Add a comment
Know the answer?
Add Answer to:
Write SQL statements that will create a Database, three Entities and the necessary tables/columns of a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • need help Create or edit the SQL statements required to accomplish the following tasks. All columns...

    need help Create or edit the SQL statements required to accomplish the following tasks. All columns should have a column name, feel free to create appropriate aliases Use screen shots to ca evidence that each task is completed; include the SQL records before and after statements are executed, as appropriate. Include all work, even if you get errors. Paste your screen shots into a single PowerPoint file pture statements output from the statements, and views of the object explorer when...

  • Provide a database schema in tabular format and provide the necessary SQL statements to build it....

    Provide a database schema in tabular format and provide the necessary SQL statements to build it. Your database should include a table with a minimum of three attributes (columns). Include the SQL statement to create the table and insert data into three rows of the table.

  • Database Management Sub-System Project SYou need to submit a project that represents a database m...

    Database Management Sub-System Project SYou need to submit a project that represents a database management sub-system to solve a specific problem (e.g. university registration sub-system, hospital sub-system, supermarket, pharmacy, etc.). SYou need to submit a documentation, which includes the following: 1. Problem Definition 2. ER-Diagram 3. Tables Mapping 4. SQL Statements 5. Screenshots of forms to insert and read the data 6. Conclusion 7. References Database Management Sub-System Project SYou need to submit a project that represents a database management...

  • Create the database and tables for the database. Show all SQL statements. Include primary and foreign...

    Create the database and tables for the database. Show all SQL statements. Include primary and foreign keys. Insert data into each table. Show select statements and display the output of each table. Note:Student’s name must be inserted into table as part of the data! Perform the SQL below: Query one table and use WHERE to filter the results. The SELECT clause should have a column list, not an asterisk (*). State the purpose of the query; show the query and...

  • Q.1] Write SQL statements based on the tennis database schema (practice homework 5) Get all the different tow...

    Q.1] Write SQL statements based on the tennis database schema (practice homework 5) Get all the different town names from the PLAYERS table. 2. For each town, find the number of players. 3. For each team, get the team number, the number of matches that has been played 'for that team, and the total number of sets won. 4. For each team that is captained by a player resident in "Eltham", get the team number and the number of matches...

  • Database For this lab you will be using SQL SELECT statements to query your database tables....

    Database For this lab you will be using SQL SELECT statements to query your database tables. You will be turning in the results of the following queries: 1. List all Patients and what Bed they are assigned to 2. List all patients who had Treatments and what Treatment they received 3. List all patients who had tests and what Test they had 4. List the employees (doctors, nurses, etc.) who assisted each patient. 5. List all patients in alphabetical order...

  • Create a database model consisting of 1) a summary of the relationships between the entities simi...

    create a database model consisting of 1) a summary of the relationships between the entities similar to Figure 6-40; 2) a crow's foot ER diagram for the design using Power Architect. Reminder: a crow's foot ERD does not contain primary keys, foreign keys, or intersection relations. Export your Power Architect diagram to a .pdf and attach it to the assignment drop box. Figure 6-40 entities and attributes to use: CEREAL_MANUFACTURERS (CMID, CMName, CMHomeState) PRODUCTS (PID, PName) INGREDIENTS (IID, IName) SUPPLIERS...

  • SQL QUERIES 1) Using the Product and PC relations, create both tables in your database and...

    SQL QUERIES 1) Using the Product and PC relations, create both tables in your database and insert all the data. Show the SQL statements to create each table and show a representative SQL insert statement for the data in each table (i.e. you do not need to show insert statements for all the data). – For the remaining questions, assume that your SQL is part of a program function and the function provides the input needed for your SQL query....

  • (SQL) Write DDL statements to create the tables below and use appropriate data types for the...

    (SQL) Write DDL statements to create the tables below and use appropriate data types for the attributes.Relational database schema: Teacher = [CourseN, Quarter,TeacherName] Course = [CourseN,CourseName, Nunit) LocationNTime = [CourseN, Quarter , DayTime, RoomN] . //Examples of DayTime: M2:00AM, W4:50PM, and T8:00PM. Note that DayTime is represented as a string. Student = [studentName, CourseN, Quarter] .................... The DDL statement must include at least the following constraints: Every Primary Key; Every Foreign Key; For every Foreign Key constraint, the referential integrity...

  • Answer the following and explain so I can double check my answers If you use the Management Studio to create a database, the Studio will automatically create a database file plus a ________________...

    Answer the following and explain so I can double check my answers If you use the Management Studio to create a database, the Studio will automatically create a database file plus a ______________________ file. 10 points    QUESTION 2 When you use the Management Studio to create a check constraint, you can specify whether you want the constraint enforced for insert or __________________ operations. 10 points    QUESTION 3 When you use the Management Studio to create a database, including its tables...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT