I am having dificulty designing a table that stores the information about a parking lot with 100 spaces that are arranged by 5 columns x 20 rows for employees, guests, handicap, executives, contractors and using an outer join sql statement.
I am using an Oracle DBMS. I have a project to do for a Database Fundamentals course in college that requires the creation of several tables (employees, retirementplan, healthplan, healthcost, healthtype, ParkingSpace).
The requirement is that the HR personnel will assign the parking space. So I am assuming that it needs a create view table or some kind of scenario where there is a prompt for HR to assign the space to that person. I am also of the mindset that each space should be named so it can be referenced. How is this accomplished. Can someone please guide me or provide the basics, please. I am a newbie so please take it easy on me. Thanks a million.
Best Answer
I drew an ER diagram for the parkinplace model.
(The dia file can be found here)
A parkingplace can be assigned to at most one employee. There may be parkingplaces that are not assigned to employes (e.g. parkingplaces for guests). One can store the column/row coordinate of each parking place. This may be expected for this homework problem. One may not do this in practice because these coordinates are not realy useful when on administrates the parking places. If there are parking places added that are not on this area then column and rows may not make sense. But if one has no column/row attribute a string attribute for specifying the location may be useful. This attribbute could hold the column/row information as string. So basically the parking place table containts 100 entries, one for each parking place.
The following script fills the tables with testdata
If you want to display all 100 parkin places with the employee names if there is an employee assigned then you have to use a
LEFT OUTER JOIN
.Because we have stored the geometrical information (row and column number) we can output the row * column matrix with the appropriate query
A demonstration can be found in sqlfiddle
This
PIVOT
extension of the select statement is implemented in Oracle since version 11. Prior version of Oracle have to use technics similar to that shown by @kkarns in a comment.